diff --git a/packages/mediacenter/xbmc-addon-xvdr/meta b/packages/mediacenter/xbmc-addon-xvdr/meta
index f43b48ef58..ab84e791c1 100644
--- a/packages/mediacenter/xbmc-addon-xvdr/meta
+++ b/packages/mediacenter/xbmc-addon-xvdr/meta
@@ -19,10 +19,7 @@
################################################################################
PKG_NAME="xbmc-addon-xvdr"
-PKG_VERSION="75445e7"
-if [ "$MEDIACENTER" = "xbmc-frodo" ]; then
- PKG_VERSION="d48e68e"
-fi
+PKG_VERSION="d48e68e"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
diff --git a/packages/mediacenter/xbmc-frodo-theme-Confluence/build b/packages/mediacenter/xbmc-frodo-theme-Confluence/build
deleted file mode 100755
index b35b583807..0000000000
--- a/packages/mediacenter/xbmc-frodo-theme-Confluence/build
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. config/options $1
-
-cd $PKG_BUILD
-TexturePacker -input media/ \
- -output Textures.xbt \
- -dupecheck \
- -use_none
diff --git a/packages/mediacenter/xbmc-frodo-theme-Confluence/install b/packages/mediacenter/xbmc-frodo-theme-Confluence/install
deleted file mode 100755
index 9e1aeaacb8..0000000000
--- a/packages/mediacenter/xbmc-frodo-theme-Confluence/install
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. config/options $1
-
-mkdir -p $INSTALL/usr/share/xbmc/addons/skin.confluence
- cp -R $PKG_BUILD/*/ $INSTALL/usr/share/xbmc/addons/skin.confluence
- cp $PKG_BUILD/*.txt $INSTALL/usr/share/xbmc/addons/skin.confluence
- cp $PKG_BUILD/*.xml $INSTALL/usr/share/xbmc/addons/skin.confluence
- cp $PKG_BUILD/*.png $INSTALL/usr/share/xbmc/addons/skin.confluence
- rm -rf $INSTALL/usr/share/xbmc/addons/skin.confluence/media
-
-mkdir -p $INSTALL/usr/share/xbmc/addons/skin.confluence/media
- cp $PKG_BUILD/Textures.xbt $INSTALL/usr/share/xbmc/addons/skin.confluence/media
diff --git a/packages/mediacenter/xbmc-frodo-theme-Confluence/meta b/packages/mediacenter/xbmc-frodo-theme-Confluence/meta
deleted file mode 100644
index 08e71cdd3e..0000000000
--- a/packages/mediacenter/xbmc-frodo-theme-Confluence/meta
+++ /dev/null
@@ -1,36 +0,0 @@
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-PKG_NAME="xbmc-frodo-theme-Confluence"
-PKG_VERSION="942a938"
-PKG_REV="1"
-PKG_ARCH="any"
-PKG_LICENSE="GPL"
-PKG_SITE="http://www.xbmc.org"
-PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
-PKG_DEPENDS=""
-PKG_BUILD_DEPENDS="toolchain"
-PKG_PRIORITY="optional"
-PKG_SECTION="mediacenter"
-PKG_SHORTDESC="xbmc-theme-Confluence: XBMC Mediacenter default theme"
-PKG_LONGDESC="XBMC Media Center (which was formerly named Xbox Media Center) is a free and open source cross-platform media player and home entertainment system software with a 10-foot user interface designed for the living-room TV. Its graphical user interface allows the user to easily manage video, photos, podcasts, and music from a computer, optical disk, local network, and the internet using a remote control."
-PKG_IS_ADDON="no"
-
-PKG_AUTORECONF="no"
diff --git a/packages/mediacenter/xbmc-frodo/build b/packages/mediacenter/xbmc-frodo/build
deleted file mode 100755
index e36b24db7e..0000000000
--- a/packages/mediacenter/xbmc-frodo/build
+++ /dev/null
@@ -1,318 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. config/options $1
-
-# disable build of GOOM until its fixed
- XBMC_VIS_GOOM="no"
-
-if [ "$DISPLAYSERVER" = "xorg-server" ]; then
- XBMC_XORG="--enable-x11 --enable-xrandr"
-else
- XBMC_XORG="--disable-x11 --disable-xrandr"
-fi
-
-if [ "$OPENGL_SUPPORT" = yes ]; then
- XBMC_OPENGL="--enable-gl"
-else
- XBMC_OPENGL="--disable-gl"
-fi
-
-if [ "$OPENGLES_SUPPORT" = yes ]; then
- XBMC_OPENGLES="--enable-gles"
-else
- XBMC_OPENGLES="--disable-gles"
-fi
-
-if [ "$SDL_SUPPORT" = yes ]; then
- XBMC_SDL="--enable-sdl"
-else
- XBMC_SDL="--disable-sdl"
-fi
-
-if [ "$XBMC_SCR_RSXS" = yes ]; then
- XBMC_RSXS="--enable-rsxs"
- # fix build of RSXS Screensaver support if not using libiconv
- if [ ! "$ICONV" = "libiconv" ]; then
- export jm_cv_func_gettimeofday_clobber=no
- fi
-else
- XBMC_RSXS="--disable-rsxs"
-fi
-
-if [ "$XBMC_VIS_PROJECTM" = yes ]; then
- XBMC_PROJECTM="--enable-projectm"
-else
- XBMC_PROJECTM="--disable-projectm"
-fi
-
-if [ "$XBMC_VIS_GOOM" = yes ]; then
- XBMC_GOOM="--enable-goom"
-else
- XBMC_GOOM="--disable-goom"
-fi
-
-if [ "$ALSA_SUPPORT" = yes ]; then
- XBMC_ALSA="--enable-alsa"
-else
- XBMC_ALSA="--disable-alsa"
-fi
-
-if [ "$PULSEAUDIO_SUPPORT" = yes ]; then
- XBMC_PULSEAUDIO="--enable-pulse"
-else
- XBMC_PULSEAUDIO="--disable-pulse"
-fi
-
-if [ "$CEC_SUPPORT" = yes ]; then
- XBMC_CEC="--enable-libcec"
- if [ "$OPENMAX" = "bcm2835-driver" ]; then
- XBMC_CEC="$XBMC_CEC --enable-rpi-cec-api"
- fi
-else
- XBMC_CEC="--disable-libcec"
-fi
-
-if [ "$JOYSTICK_SUPPORT" = yes ]; then
- XBMC_JOYSTICK="--enable-joystick"
-else
- XBMC_JOYSTICK="--disable-joystick"
-fi
-
-if [ "$NONFREE_SUPPORT" = yes ]; then
- XBMC_NONFREE="--enable-non-free"
-else
- XBMC_NONFREE="--disable-non-free"
-fi
-
-if [ "$AIRPLAY_SUPPORT" = yes ]; then
- XBMC_AIRPLAY="--enable-airplay"
-else
- XBMC_AIRPLAY="--disable-airplay"
-fi
-
-if [ "$AIRTUNES_SUPPORT" = yes ]; then
- XBMC_AIRTUNES="--enable-airtunes"
-else
- XBMC_AIRTUNES="--disable-airtunes"
-fi
-
-if [ "$DVDCSS_SUPPORT" = yes ]; then
- XBMC_DVDCSS="--enable-dvdcss"
-else
- XBMC_DVDCSS="--disable-dvdcss"
-fi
-
-if [ "$ENCODER_LAME" = yes ]; then
- XBMC_LAMEENC="--enable-libmp3lame"
-else
- XBMC_LAMEENC="--disable-libmp3lame"
-fi
-
-if [ "$ENCODER_VORBIS" = yes ]; then
- XBMC_VORBISENC="--enable-libvorbisenc"
-else
- XBMC_VORBISENC="--disable-libvorbisenc"
-fi
-
-if [ "$BLURAY_SUPPORT" = yes ]; then
- XBMC_BLURAY="--enable-libbluray"
-else
- XBMC_BLURAY="--disable-libbluray"
-fi
-
-if [ "$AVAHI_DAEMON" = yes ]; then
- XBMC_AVAHI="--enable-avahi"
-else
- XBMC_AVAHI="--disable-avahi"
-fi
-
-if [ "$NFS_SUPPORT" = yes ]; then
- XBMC_NFS="--enable-nfs"
-else
- XBMC_NFS="--disable-nfs"
-fi
-
-if [ "$AFP_SUPPORT" = yes ]; then
- XBMC_AFP="--enable-afpclient"
-else
- XBMC_AFP="--disable-afpclient"
-fi
-
-if [ "$SAMBA_CLIENT" = yes ]; then
- XBMC_SAMBA="--enable-samba"
- export LIBS="$LIBS -ltalloc -ltdb -lwbclient"
-else
- XBMC_SAMBA="--disable-samba"
-fi
-
-if [ "$WEBSERVER" = yes ]; then
- XBMC_WEBSERVER="--enable-webserver"
-else
- XBMC_WEBSERVER="--disable-webserver"
-fi
-
-if [ "$OPENMAX_SUPPORT" = yes ]; then
- XBMC_OPENMAX="--enable-openmax"
- if [ "$OPENMAX" = "bcm2835-driver" ]; then
- XBMC_PLATFORM_SUPPORT="--with-platform=raspberry-pi"
- XBMC_PLAYER="--enable-player=omxplayer"
- CFLAGS="$CFLAGS -I$SYSROOT_PREFIX/usr/include/interface/vcos/pthreads/"
- CXXFLAGS="$CXXFLAGS -I$SYSROOT_PREFIX/usr/include/interface/vcos/pthreads/"
- fi
-else
- XBMC_OPENMAX="--disable-openmax"
-fi
-
-if [ "$VDPAU" = yes ]; then
- XBMC_VDPAU="--enable-vdpau"
-else
- XBMC_VDPAU="--disable-vdpau"
-fi
-
-if [ "$VAAPI" = yes ]; then
- XBMC_VAAPI="--enable-vaapi"
-else
- XBMC_VAAPI="--disable-vaapi"
-fi
-
-if [ "$XVBA" = yes ]; then
- XBMC_XVBA="--enable-xvba"
-else
- XBMC_XVBA="--disable-xvba"
-fi
-
-if [ "$CRYSTALHD" = yes ]; then
- XBMC_CRYSTALHD="--enable-crystalhd"
-else
- XBMC_CRYSTALHD="--disable-crystalhd"
-fi
-
-# xbmc fails to build with LTO optimization
- strip_lto
-
-# dont use some optimizations because of build problems
- LDFLAGS=`echo $LDFLAGS | sed -e "s|-Wl,--as-needed||"`
-
-# dont build parallel
- MAKEFLAGS=-j1
-
- export PYTHON_VERSION="2.7"
- export PYTHON_CPPFLAGS="-I$SYSROOT_PREFIX/usr/include/python$PYTHON_VERSION"
- export PYTHON_LDFLAGS="-L$SYSROOT_PREFIX/usr/lib/python$PYTHON_VERSION -lpython$PYTHON_VERSION"
- export PYTHON_SITE_PKG="$SYSROOT_PREFIX/usr/lib/python$PYTHON_VERSION/site-packages"
- export ac_python_version="$PYTHON_VERSION"
-
-# setup skin dir from default skin
- SKIN_DIR="skin.`tolower $SKIN_DEFAULT`"
-
-cd $PKG_BUILD
-
-# adding fake Makefile for stripped skin
- mkdir -p addons/skin.confluence/media
- touch addons/skin.confluence/media/Makefile.in
-
-# autoreconf
- do_autoreconf
- do_autoreconf lib/libid3tag/libid3tag
- do_autoreconf xbmc/screensavers/rsxs-0.9
- do_autoreconf xbmc/visualizations/Goom/goom2k4-0
- do_autoreconf lib/libapetag
- do_autoreconf lib/cpluff
- # order matters with libdvd and friends
- [ -d lib/libdvd/libdvdcss ] && do_autoreconf lib/libdvd/libdvdcss
- do_autoreconf lib/libdvd/libdvdread
- do_autoreconf lib/libdvd/libdvdnav
-
-# Clean the generated files
- find . -depth -type d -name "autom4te.cache" -exec rm -rf {} \;
-
-./configure --host=$TARGET_NAME \
- --build=$HOST_NAME \
- --with-arch=$TARGET_ARCH \
- --with-cpu=$TARGET_CPU \
- --prefix=/usr \
- --exec-prefix=/usr \
- --sysconfdir=/etc \
- --datadir=/usr/share \
- GIT_REV=`cat git.version` \
- --disable-debug \
- --disable-optimizations \
- $XBMC_OPENGL \
- $XBMC_OPENGLES \
- $XBMC_SDL \
- $XBMC_OPENMAX \
- $XBMC_VDPAU \
- $XBMC_VAAPI \
- $XBMC_CRYSTALHD \
- $XBMC_XVBA \
- --disable-vdadecoder \
- --disable-vtbdecoder \
- --disable-tegra \
- --disable-profiling \
- $XBMC_JOYSTICK \
- $XBMC_CEC \
- --enable-udev \
- --disable-libusb \
- $XBMC_GOOM \
- $XBMC_RSXS \
- $XBMC_PROJECTM \
- $XBMC_XORG \
- --disable-ccache \
- $XBMC_ALSA \
- $XBMC_PULSEAUDIO \
- --enable-rtmp \
- $XBMC_SAMBA \
- $XBMC_NFS \
- $XBMC_AFP \
- $XBMC_VORBISENC \
- --enable-ffmpeg-libvorbis \
- $XBMC_LAMEENC \
- $XBMC_DVDCSS \
- --disable-mid \
- --disable-hal \
- $XBMC_AVAHI \
- $XBMC_AIRPLAY \
- $XBMC_AIRTUNES \
- $XBMC_NONFREE \
- --disable-asap-codec \
- $XBMC_WEBSERVER \
- --enable-optical-drive \
- $XBMC_BLURAY \
- --enable-texturepacker --with-texturepacker-root="$ROOT/$TOOLCHAIN" \
- --disable-external-libraries \
- --enable-external-ffmpeg \
- $XBMC_PLATFORM_SUPPORT \
- $XBMC_PLAYER \
-
-# setup default skin inside the sources
- sed -i -e "s|skin.confluence|$SKIN_DIR|g" xbmc/settings/Settings.h
-
-make externals
-make xbmc.bin
-
-if [ "$DISPLAYSERVER" = "xorg-server" ]; then
- make xbmc-xrandr
-fi
-
-make -C tools/TexturePacker
-cp -PR tools/TexturePacker/TexturePacker $ROOT/$TOOLCHAIN/bin
diff --git a/packages/mediacenter/xbmc-frodo/config/advancedsettings.xml b/packages/mediacenter/xbmc-frodo/config/advancedsettings.xml
deleted file mode 100644
index 8027b986e4..0000000000
--- a/packages/mediacenter/xbmc-frodo/config/advancedsettings.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- false
- false
- cputemp
- gputemp
-
-
- 30
-
-
diff --git a/packages/mediacenter/xbmc-frodo/config/os.openelec.tv/addon.xml b/packages/mediacenter/xbmc-frodo/config/os.openelec.tv/addon.xml
deleted file mode 100644
index b1ed65be99..0000000000
--- a/packages/mediacenter/xbmc-frodo/config/os.openelec.tv/addon.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/packages/mediacenter/xbmc-frodo/config/repository.openelec.tv/addon.xml b/packages/mediacenter/xbmc-frodo/config/repository.openelec.tv/addon.xml
deleted file mode 100644
index d715467e85..0000000000
--- a/packages/mediacenter/xbmc-frodo/config/repository.openelec.tv/addon.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- @ADDON_URL@/addons.xml
- @ADDON_URL@/addons.xml.md5
- @ADDON_URL@
-
-
- Install Add-ons, Plugins, Games and Programs from [COLOR FF757677]Open[/COLOR][COLOR FF8ABEE2]ELEC[/COLOR]
- Download and install Add-ons, Plugins, Games and Programs from the Official [COLOR FF757677]Open[/COLOR][COLOR FF8ABEE2]ELEC[/COLOR] addon repository.[CR] By using the official Repository you will be able to take advantage of our extensive file mirror service to help get you faster downloads from a region close to you.[CR] All addons on this repository have under gone basic testing, if you find a broken or not working addon please report it to [COLOR FF757677]Open[/COLOR][COLOR FF8ABEE2]ELEC[/COLOR] so we can take any action needed.
- all
-
-
diff --git a/packages/mediacenter/xbmc-frodo/config/repository.openelec.tv/icon.png b/packages/mediacenter/xbmc-frodo/config/repository.openelec.tv/icon.png
deleted file mode 100644
index 1147ae1d37..0000000000
Binary files a/packages/mediacenter/xbmc-frodo/config/repository.openelec.tv/icon.png and /dev/null differ
diff --git a/packages/mediacenter/xbmc-frodo/fonts/DejaVuSans.ttf b/packages/mediacenter/xbmc-frodo/fonts/DejaVuSans.ttf
deleted file mode 100644
index 84ca1d7503..0000000000
Binary files a/packages/mediacenter/xbmc-frodo/fonts/DejaVuSans.ttf and /dev/null differ
diff --git a/packages/mediacenter/xbmc-frodo/fonts/Trebuchet MS Bold.ttf b/packages/mediacenter/xbmc-frodo/fonts/Trebuchet MS Bold.ttf
deleted file mode 100644
index 867f56d776..0000000000
Binary files a/packages/mediacenter/xbmc-frodo/fonts/Trebuchet MS Bold.ttf and /dev/null differ
diff --git a/packages/mediacenter/xbmc-frodo/fonts/YanoneKaffeesatz-Bold.ttf b/packages/mediacenter/xbmc-frodo/fonts/YanoneKaffeesatz-Bold.ttf
deleted file mode 100644
index e9964b0809..0000000000
Binary files a/packages/mediacenter/xbmc-frodo/fonts/YanoneKaffeesatz-Bold.ttf and /dev/null differ
diff --git a/packages/mediacenter/xbmc-frodo/init.d/91_cleanup-logfiles b/packages/mediacenter/xbmc-frodo/init.d/91_cleanup-logfiles
deleted file mode 100644
index 7f479fe516..0000000000
--- a/packages/mediacenter/xbmc-frodo/init.d/91_cleanup-logfiles
+++ /dev/null
@@ -1,27 +0,0 @@
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-# starting XBMC
-#
-# runlevels: openelec
-
-progress "clean up log files"
- rm -f /storage/.xbmc/userdata/addon_data/*/*.log 2>/dev/null
- rm -rf /storage/.xbmc/userdata/addon_data/*/log/* 2>/dev/null
diff --git a/packages/mediacenter/xbmc-frodo/init.d/92_setup-xbmc b/packages/mediacenter/xbmc-frodo/init.d/92_setup-xbmc
deleted file mode 100644
index 7075f3d3fe..0000000000
--- a/packages/mediacenter/xbmc-frodo/init.d/92_setup-xbmc
+++ /dev/null
@@ -1,123 +0,0 @@
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-# setup XBMC
-#
-# runlevels: openelec
-
-progress "setup XBMC"
-
-#
-# clean temp dir
-#
- rm -rf $HOME/.xbmc/temp/*
-
-#
-# add some default settings
-#
- mkdir -p $HOME/.xbmc/userdata
-
-#
-# setup directories for XBMC sources
-#
-
- [ ! -d "$HOME/music" ] && mkdir -p $HOME/music
- [ ! -d "$HOME/pictures" ] && mkdir -p $HOME/pictures
- [ ! -d "$HOME/tvshows" ] && mkdir -p $HOME/tvshows
- [ ! -d "$HOME/videos" ] && mkdir -p $HOME/videos
-
- mkdir -p $HOME/.xbmc/userdata
-
- if [ ! -f $HOME/.xbmc/userdata/sources.xml ]; then
- if [ -f /usr/share/xbmc/config/sources.xml ]; then
- # include project specific sources
- cp /usr/share/xbmc/config/sources.xml $HOME/.xbmc/userdata
- else
- cat > $HOME/.xbmc/userdata/sources.xml << EOF
-
-
-
-
-
- Music
- $HOME/music/
-
-
-
-
-
- Pictures
- $HOME/pictures/
-
-
-
-EOF
- fi
- fi
-
-#
-# common setup guisettings
-#
-
- mkdir -p $HOME/.xbmc/userdata
-
- [ ! -d "$HOME/screenshots" ] && mkdir -p $HOME/screenshots
-
- if [ ! -f $HOME/.xbmc/userdata/guisettings.xml ] ; then
- echo "" > $HOME/.xbmc/userdata/guisettings.xml
-
- cat >> $HOME/.xbmc/userdata/guisettings.xml << EOF
-
- $HOME/screenshots/
-
-EOF
-
- #
- # include project specific options
- #
-
- if [ -f /usr/share/xbmc/config/guisettings.xml ]; then
- cat /usr/share/xbmc/config/guisettings.xml >> $HOME/.xbmc/userdata/guisettings.xml
- fi
-
- #
- # common setup for amd and nvidia graphic
- #
-
- # Always sync to vblank
- if [ "$GPUTYPE" = "NVIDIA" -o "$GPUTYPE" = "AMD" ] ; then
- cat >> $HOME/.xbmc/userdata/guisettings.xml << EOF
-
- 2
-
-EOF
- fi
- echo "" >> $HOME/.xbmc/userdata/guisettings.xml
- fi
diff --git a/packages/mediacenter/xbmc-frodo/init.d/93_xbmc b/packages/mediacenter/xbmc-frodo/init.d/93_xbmc
deleted file mode 100644
index 164310c603..0000000000
--- a/packages/mediacenter/xbmc-frodo/init.d/93_xbmc
+++ /dev/null
@@ -1,106 +0,0 @@
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-# starting XBMC
-#
-# runlevels: openelec
-
-LIRCDEV="/var/run/lirc/lircd"
-[ -e /var/run/lirc/lircd.irtrans ] && LIRCDEV="/var/run/lirc/lircd.irtrans"
-XBMC_ARGS="--standalone -fs --lircdev $LIRCDEV"
-
-progress "starting XBMC"
-
-# hack for Boxee Remote
-if grep -q "Vendor=0471 Product=20d9" /proc/bus/input/devices; then
- export SDL_MOUSE_RELATIVE=0
-fi
-
-# hack: make addon-bins executable
- chmod +x /storage/.xbmc/addons/*/bin/* > /dev/null 2>&1
-
-# starting autostart script (will be removed later again, dont use it!!!)
- AUTOSTART="/storage/.config/autostart.sh"
- if [ -f $AUTOSTART ]; then
- echo "!!! AUTOSTART script detected !!!" >> /var/log/messages
- cat "$AUTOSTART" >> /var/log/messages
- echo "!!! -End of autostart script- !!!" >> /var/log/messages
-
- sh $AUTOSTART
- fi
-
-# starting autoupdate
- [ -f /usr/bin/autoupdate ] && /usr/bin/autoupdate &
-
-# waiting for Xorg to start
- wait_for_xorg
-
-# set cpu's to 'conservative'
- ( usleep 15000000
- progress "set cpu's to 'ondemand'"
- cpupower frequency-set -g ondemand > /dev/null 2>&1
- )&
-
-# prevent restrating XBMC at reboot or shutdown
- LOCKDIR="/var/lock/"
- LOCKFILE="xbmc.disabled"
- [ -f "$LOCKDIR/$LOCKFILE" ] && rm -f "$LOCKDIR/$LOCKFILE" &
-
-# starting XBMC
- usleep $XBMC_STARTDELAY
- while true; do
-
- while [ -f "$LOCKDIR/$LOCKFILE" ]; do
- usleep 250000
- done
-
- DISPLAY=:0.0 /usr/lib/xbmc/xbmc.bin $XBMC_ARGS > /dev/null 2>&1
- RET=$?
-
- case "$RET" in
- 0)
- if [ ! $(pidof console-kit-daemon) ]; then
- touch "$LOCKDIR/$LOCKFILE"
- poweroff -f
- fi
- ;;
- 64)
- if [ ! $(pidof console-kit-daemon) ]; then
- touch "$LOCKDIR/$LOCKFILE"
- poweroff -f
- fi
- ;;
- 66)
- if [ ! $(pidof console-kit-daemon) ]; then
- touch "$LOCKDIR/$LOCKFILE"
- reboot
- fi
- ;;
- 255)
- echo "Abnormal Exit. Exited with code $RET"
- echo "is Xorg running? check /var/log/Xorg.log"
- ;;
- *)
- echo "Abnormal Exit. Exited with code $RET"
- ;;
- esac
-
- usleep 250000
- done
diff --git a/packages/mediacenter/xbmc-frodo/install b/packages/mediacenter/xbmc-frodo/install
deleted file mode 100755
index 90983e8427..0000000000
--- a/packages/mediacenter/xbmc-frodo/install
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. config/options $1
-
-PYTHON_LIBDIR="`ls -d $INSTALL/usr/lib/python*`"
-
-mkdir -p $INSTALL/usr/bin
- cp $PKG_DIR/scripts/cputemp $INSTALL/usr/bin
- cp $PKG_DIR/scripts/gputemp $INSTALL/usr/bin
- cp $PKG_DIR/scripts/wait_on_xbmc_exit $INSTALL/usr/bin
- cp $PKG_BUILD/tools/EventClients/Clients/XBMC\ Send/xbmc-send.py $INSTALL/usr/bin/xbmc-send
- cp $PKG_DIR/scripts/setwakeup.sh $INSTALL/usr/bin
-
-mkdir -p $INSTALL/usr/lib/xbmc
- cp $PKG_BUILD/xbmc.bin $INSTALL/usr/lib/xbmc
- if [ "$DISPLAYSERVER" = "xorg-server" ]; then
- cp $PKG_BUILD/xbmc-xrandr $INSTALL/usr/lib/xbmc
- fi
-
-cd $PKG_BUILD
- find system addons \
- -regextype posix-extended -type f \
- -not -iregex ".*svn.*|.*win32(dx)?\.vis|.*osx\.vis" \
- -iregex ".*-linux.*|.*-arm.*|.*\.vis|.*\.xbs" \
- -exec install -D "{}" $ROOT/$INSTALL/usr/lib/xbmc/"{}" ";"
-
- find addons language media sounds userdata system \
- -regextype posix-extended -type f \
- -not -iregex ".*-linux.*|.*-arm.*|.*\.vis|.*\.xbs|.*svn.*|.*\.orig|.*\.so|.*\.dll|.*\.pyd|.*python|.*\.zlib|.*\.conf" \
- -exec install -D -m 0644 "{}" $ROOT/$INSTALL/usr/share/xbmc/"{}" ";"
-cd -
-
-if [ ! "$XBMC_SCR_RSXS" = yes ]; then
- rm -rf $ROOT/$INSTALL/usr/share/xbmc/addons/screensaver.rsxs.*
-fi
-
-if [ ! "$XBMC_VIS_PROJECTM" = yes ]; then
- rm -rf $ROOT/$INSTALL/usr/share/xbmc/addons/visualization.projectm
-fi
-
-rm -rf $ROOT/$INSTALL/usr/share/xbmc/addons/visualization.dxspectrum
-rm -rf $ROOT/$INSTALL/usr/share/xbmc/addons/visualization.itunes
-rm -rf $ROOT/$INSTALL/usr/share/xbmc/addons/visualization.milkdrop
-
-# overriding Splash image
-mkdir -p $INSTALL/usr/share/xbmc/media
- rm -rf $INSTALL/usr/share/xbmc/media/Splash.png
-# if [ -f $PROJECT_DIR/$PROJECT/splash/splash.png ]; then
-# cp $PROJECT_DIR/$PROJECT/splash/splash.png $INSTALL/usr/share/xbmc/media/Splash.png
-# else
-# cp $PKG_DIR/splash/splash.png $INSTALL/usr/share/xbmc/media/Splash.png
-# fi
-
-# cleanup and python addon fixes
- rm -rf $INSTALL/usr/share/xbmc/addons/script.module.pysqlite
- rm -rf $INSTALL/usr/share/xbmc/addons/script.module.simplejson
-
-mkdir -p $INSTALL/usr/share/xbmc/addons
- cp -R $PKG_DIR/config/os.openelec.tv $INSTALL/usr/share/xbmc/addons
- $SED "s|@OS_VERSION@|$OS_VERSION|g" -i $INSTALL/usr/share/xbmc/addons/os.openelec.tv/addon.xml
- cp -R $PKG_DIR/config/repository.openelec.tv $INSTALL/usr/share/xbmc/addons
- $SED "s|@ADDON_URL@|$ADDON_URL|g" -i $INSTALL/usr/share/xbmc/addons/repository.openelec.tv/addon.xml
-
-mkdir -p $PYTHON_LIBDIR/site-packages/xbmc
- cp -R $PKG_BUILD/tools/EventClients/lib/python/* $PYTHON_LIBDIR/site-packages/xbmc
-
-# install powermanagement hooks
- mkdir -p $INSTALL/etc/pm/sleep.d
- cp $PKG_DIR/sleep.d/* $INSTALL/etc/pm/sleep.d
-
-# install project specific configs
- mkdir -p $INSTALL/usr/share/xbmc/config
- if [ -f $PROJECT_DIR/$PROJECT/xbmc/guisettings.xml ]; then
- cp -R $PROJECT_DIR/$PROJECT/xbmc/guisettings.xml $INSTALL/usr/share/xbmc/config
- fi
-
- if [ -f $PROJECT_DIR/$PROJECT/xbmc/sources.xml ]; then
- cp -R $PROJECT_DIR/$PROJECT/xbmc/sources.xml $INSTALL/usr/share/xbmc/config
- fi
-
- mkdir -p $INSTALL/usr/share/xbmc/system/
- if [ -f $PROJECT_DIR/$PROJECT/xbmc/advancedsettings.xml ]; then
- cp $PROJECT_DIR/$PROJECT/xbmc/advancedsettings.xml $INSTALL/usr/share/xbmc/system/
- else
- cp $PKG_DIR/config/advancedsettings.xml $INSTALL/usr/share/xbmc/system/
- fi
-
-if [ "$XBMC_EXTRA_FONTS" = yes ]; then
- mkdir -p $INSTALL/usr/share/xbmc/media/Fonts
- cp $PKG_DIR/fonts/*.ttf $INSTALL/usr/share/xbmc/media/Fonts
-fi
diff --git a/packages/mediacenter/xbmc-frodo/meta b/packages/mediacenter/xbmc-frodo/meta
deleted file mode 100644
index e28f2c60dc..0000000000
--- a/packages/mediacenter/xbmc-frodo/meta
+++ /dev/null
@@ -1,177 +0,0 @@
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-PKG_NAME="xbmc-frodo"
-PKG_VERSION="942a938"
-PKG_REV="1"
-PKG_ARCH="any"
-PKG_LICENSE="GPL"
-PKG_SITE="http://www.xbmc.org"
-PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
-PKG_DEPENDS="boost Python zlib bzip2 systemd pcre ffmpeg libass curl libssh rtmpdump fontconfig tinyxml freetype libmad libogg libmodplug faad2 flac libmpeg2 taglib yajl sqlite bc xbmc-addon-settings"
-PKG_BUILD_DEPENDS="toolchain boost Python zlib bzip2 systemd lzo pcre swig ffmpeg libass enca curl libssh rtmpdump fontconfig fribidi tinyxml libjpeg-turbo libpng tiff freetype jasper libmad libsamplerate libogg libcdio libmodplug faad2 flac libmpeg2 taglib yajl sqlite mysql"
-PKG_PRIORITY="optional"
-PKG_SECTION="mediacenter"
-PKG_SHORTDESC="xbmc: XBMC Mediacenter"
-PKG_LONGDESC="XBMC Media Center (which was formerly named Xbox Media Center) is a free and open source cross-platform media player and home entertainment system software with a 10-foot user interface designed for the living-room TV. Its graphical user interface allows the user to easily manage video, photos, podcasts, and music from a computer, optical disk, local network, and the internet using a remote control."
-PKG_IS_ADDON="no"
-
-PKG_AUTORECONF="no"
-
-# needed for hosttools (Texturepacker)
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS lzo-host SDL-host SDL_image-host"
-
-# some python stuff needed for various addons
- PKG_DEPENDS="$PKG_DEPENDS Imaging"
- PKG_DEPENDS="$PKG_DEPENDS simplejson"
-
-# various PVR clients
- PKG_DEPENDS="$PKG_DEPENDS xbmc-pvr-addons"
-# PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-njoy"
- PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-vuplus"
- PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr"
-
-if [ "$DISPLAYSERVER" = "xorg-server" ]; then
- # for libX11 support
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libX11 libXext"
- PKG_DEPENDS="$PKG_DEPENDS libX11 libXext"
-
- # for libXrandr support
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libXrandr"
- PKG_DEPENDS="$PKG_DEPENDS libXrandr"
-
- # for SDL support
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS SDL SDL_image"
- PKG_DEPENDS="$PKG_DEPENDS SDL SDL_image"
-fi
-
-if [ "$OPENGL_SUPPORT" = yes ]; then
- # for OpenGL (GLX) support
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS $OPENGL glew"
- PKG_DEPENDS="$PKG_DEPENDS $OPENGL glew"
-fi
-
-if [ "$OPENGLES_SUPPORT" = yes ]; then
- # for OpenGL-ES support
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS $OPENGLES"
- PKG_DEPENDS="$PKG_DEPENDS $OPENGLES"
-fi
-
-# for dbus support
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS dbus"
- PKG_DEPENDS="$PKG_DEPENDS dbus"
-
-if [ "$ALSA_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS alsa-lib"
- PKG_DEPENDS="$PKG_DEPENDS alsa alsa-lib"
-fi
-
-if [ "$PULSEAUDIO_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS pulseaudio"
- PKG_DEPENDS="$PKG_DEPENDS pulseaudio"
-fi
-
-if [ "$CEC_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libcec"
- PKG_DEPENDS="$PKG_DEPENDS libcec"
-fi
-
-if [ "$XBMC_SCR_RSXS" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libXt libXmu"
- PKG_DEPENDS="$PKG_DEPENDS libXt libXmu"
-fi
-
-if [ "$FAAC_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS faac"
- PKG_DEPENDS="$PKG_DEPENDS faac"
-fi
-
-if [ "$ENCODER_LAME" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS lame"
- PKG_DEPENDS="$PKG_DEPENDS lame"
-fi
-
-if [ "$ENCODER_VORBIS" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libvorbis"
- PKG_DEPENDS="$PKG_DEPENDS libvorbis"
-fi
-
-if [ "$BLURAY_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libbluray"
- PKG_DEPENDS="$PKG_DEPENDS libbluray"
-fi
-
-if [ "$AVAHI_DAEMON" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS avahi"
- PKG_DEPENDS="$PKG_DEPENDS avahi"
-fi
-
-if [ "$AIRPLAY_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libplist"
- PKG_DEPENDS="$PKG_DEPENDS libplist"
-fi
-
-if [ "$AIRTUNES_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libshairport"
- PKG_DEPENDS="$PKG_DEPENDS libshairport"
-fi
-
-if [ "$NFS_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libnfs"
- PKG_DEPENDS="$PKG_DEPENDS libnfs"
-fi
-
-if [ "$AFP_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS afpfs-ng"
- PKG_DEPENDS="$PKG_DEPENDS afpfs-ng"
-fi
-
-if [ "$SAMBA_CLIENT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS samba"
- PKG_DEPENDS="$PKG_DEPENDS samba"
-fi
-
-if [ "$WEBSERVER" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libmicrohttpd"
-fi
-
-if [ "$OPENMAX_SUPPORT" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS $OPENMAX"
- PKG_DEPENDS="$PKG_DEPENDS $OPENMAX"
-fi
-
-if [ "$VDPAU" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libvdpau"
- PKG_DEPENDS="$PKG_DEPENDS libvdpau"
-fi
-
-if [ "$VAAPI" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libva"
- PKG_DEPENDS="$PKG_DEPENDS libva"
-fi
-
-if [ "$CRYSTALHD" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS crystalhd"
- PKG_DEPENDS="$PKG_DEPENDS crystalhd"
-fi
-
-if [ "$XVBA" = yes ]; then
- PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS xf86-video-fglrx"
-fi
diff --git a/packages/mediacenter/xbmc-frodo/patches/rename.sh b/packages/mediacenter/xbmc-frodo/patches/rename.sh
deleted file mode 100755
index 21b155f7be..0000000000
--- a/packages/mediacenter/xbmc-frodo/patches/rename.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-for i in `ls xbmc-*.patch`; do
- mv $i `echo $i | sed "s,$1,$2,g"`
-done
diff --git a/packages/mediacenter/xbmc-frodo/profile.d/xbmc.conf b/packages/mediacenter/xbmc-frodo/profile.d/xbmc.conf
deleted file mode 100644
index 7029bf1bd3..0000000000
--- a/packages/mediacenter/xbmc-frodo/profile.d/xbmc.conf
+++ /dev/null
@@ -1,44 +0,0 @@
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-# Mediacenter environment variables.
-#
-# This file contains non-OpenELEC evironment variables as well as OpenELEC
-# evironment variables that are not user defined.
-################################################################################
-
-if [ -z "$XBMC_STARTDELAY" ]; then
- XBMC_STARTDELAY="1000000"
-fi
-
-XBMC_HOME="/usr/share/xbmc"
-
-export XBMC_HOME
-
-GPUTYPE="OTHER"
-
-if [ -x /usr/bin/lspci ]; then
- GPUDEVICE=$(lspci -n | grep 0300)
-
- [ "$(echo $GPUDEVICE | grep 8086)" ] && GPUTYPE="INTEL" # 8086 == INTEL
- [ "$(echo $GPUDEVICE | grep 10de)" ] && GPUTYPE="NVIDIA" # 10de == NVIDIA
- [ "$(echo $GPUDEVICE | grep 1002)" ] && GPUTYPE="AMD" # 1002 == AMD
-fi
-
-export GPUTYPE
diff --git a/packages/mediacenter/xbmc-frodo/scripts/cputemp b/packages/mediacenter/xbmc-frodo/scripts/cputemp
deleted file mode 100755
index 2a6e7d556a..0000000000
--- a/packages/mediacenter/xbmc-frodo/scripts/cputemp
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-# inspired by
-# https://github.com/xtranophilist/gnome-shell-extension-cpu-temperature/blob/master/extension.js
-
-TEMP=0
-
-if [ -f /sys/devices/platform/coretemp.0/temp1_input ]; then
- # used with coretemp
- TEMP=`cat /sys/devices/platform/coretemp.0/temp1_input`
-elif [ -f /sys/devices/platform/coretemp.0/temp2_input ]; then
- # used with coretemp
- TEMP=`cat /sys/devices/platform/coretemp.0/temp2_input`
-elif [ -f /sys/bus/acpi/devices/LNXTHERM\:00/thermal_zone/temp ]; then
- # used on some intel systems
- TEMP=`cat /sys/bus/acpi/devices/LNXTHERM\:00/thermal_zone/temp`
-elif [ -f /sys/devices/virtual/thermal/thermal_zone0/temp ]; then
- # used on some intel systems
- TEMP=`cat /sys/devices/virtual/thermal/thermal_zone0/temp`
-elif [ -f /sys/class/hwmon/hwmon0/temp1_input ]; then
- # hwmon for new 2.6.39, 3.0 linux kernels
- TEMP=`cat /sys/class/hwmon/hwmon0/temp1_input`
-elif [ -f /sys/class/hwmon/hwmon0/device/temp1_input ]; then
- # used on AMD systems
- TEMP=`cat /sys/class/hwmon/hwmon0/device/temp1_input`
-elif [ -f /sys/class/hwmon/hwmon0/device/temp2_input ]; then
- # used on ION systems
- TEMP=`cat /sys/class/hwmon/hwmon0/device/temp2_input`
-elif [ -f /sys/class/thermal/thermal_zone0/temp ]; then
- # used on RaspberryPi
- TEMP=`cat /sys/class/thermal/thermal_zone0/temp`
-fi
-
-echo "$(( $TEMP / 1000 )) C"
diff --git a/packages/mediacenter/xbmc-frodo/scripts/gputemp b/packages/mediacenter/xbmc-frodo/scripts/gputemp
deleted file mode 100755
index d5152aa4f6..0000000000
--- a/packages/mediacenter/xbmc-frodo/scripts/gputemp
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-TEMP="0"
-
-if lspci -n | grep 0300 | grep -q 10de; then
- [ -f /usr/bin/nvidia-smi ] && TEMP=`/usr/bin/nvidia-smi -q -x | grep 'gpu_temp' | awk '{ print $1 }' | sed 's,,,g'`
-fi
-
-if lspci -n | grep 0300 | grep -q 1002; then
- if [ -f /storage/.config/xorg.conf ]; then
- XORG="/storage/.config/xorg.conf"
- else
- XORG="/etc/X11/xorg-fglrx.conf"
- fi
- [ -f /usr/bin/aticonfig ] && TEMP=`/usr/bin/aticonfig -i $XORG --od-gettemperature | grep Temperature | cut -f 2 -d "-" | cut -f 1 -d "." | sed -e "s, ,,"`
-fi
-
-echo "${TEMP} C"
diff --git a/packages/mediacenter/xbmc-frodo/scripts/setwakeup.sh b/packages/mediacenter/xbmc-frodo/scripts/setwakeup.sh
deleted file mode 100755
index 557abff270..0000000000
--- a/packages/mediacenter/xbmc-frodo/scripts/setwakeup.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-if [ -f /sys/class/rtc/rtc0/wakealarm ]; then
- logger -t setwakeup.sh "### Setting system wakeup time ###"
- echo 0 > /sys/class/rtc/rtc0/wakealarm
- echo $1 > /sys/class/rtc/rtc0/wakealarm
- logger -t setwakeup.sh "### $(cat /proc/driver/rtc) ###"
-fi
diff --git a/packages/mediacenter/xbmc-frodo/scripts/wait_on_xbmc_exit b/packages/mediacenter/xbmc-frodo/scripts/wait_on_xbmc_exit
deleted file mode 100755
index 60efb36402..0000000000
--- a/packages/mediacenter/xbmc-frodo/scripts/wait_on_xbmc_exit
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-count=0
-
-while [ $(pidof xbmc.bin) -a $count -le 20 ]; do
- usleep 250000
- logger -t wait_on_xbmc_exit "### Waiting for XBMC to Exit - $count ###"
- count=$((count+1))
-done
diff --git a/packages/mediacenter/xbmc-frodo/sleep.d/00_addon-sleep b/packages/mediacenter/xbmc-frodo/sleep.d/00_addon-sleep
deleted file mode 100755
index 01c9653b45..0000000000
--- a/packages/mediacenter/xbmc-frodo/sleep.d/00_addon-sleep
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. /etc/profile
-
-for script in $HOME/.xbmc/addons/*/sleep.d/*.power; do
- progress "running addon sleep script $script ($1)..."
- sh $script $1
-done
diff --git a/packages/mediacenter/xbmc-frodo/sleep.d/61_xbmc_lirc b/packages/mediacenter/xbmc-frodo/sleep.d/61_xbmc_lirc
deleted file mode 100755
index 0cb99c757e..0000000000
--- a/packages/mediacenter/xbmc-frodo/sleep.d/61_xbmc_lirc
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. /etc/profile
-
-case "$1" in
- hibernate|suspend)
- xbmc-send --host=127.0.0.1 -a "LIRC.Stop"
- ;;
- thaw|resume)
- xbmc-send --host=127.0.0.1 -a "LIRC.Start"
- ;;
- *) exit $NA
- ;;
-esac
diff --git a/packages/mediacenter/xbmc-frodo/sleep.d/62_xbmc_lcd b/packages/mediacenter/xbmc-frodo/sleep.d/62_xbmc_lcd
deleted file mode 100755
index a3f8e358a4..0000000000
--- a/packages/mediacenter/xbmc-frodo/sleep.d/62_xbmc_lcd
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. /etc/profile
-
-case "$1" in
- hibernate|suspend)
- xbmc-send --host=127.0.0.1 -a "LCD.Suspend"
- ;;
- thaw|resume)
- xbmc-send --host=127.0.0.1 -a "LCD.Resume"
- ;;
- *) exit $NA
- ;;
-esac
diff --git a/packages/mediacenter/xbmc-frodo/sleep.d/99_reload_skin b/packages/mediacenter/xbmc-frodo/sleep.d/99_reload_skin
deleted file mode 100755
index eb3a3dce07..0000000000
--- a/packages/mediacenter/xbmc-frodo/sleep.d/99_reload_skin
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. /etc/profile
-
-case "$1" in
- thaw|resume)
- xbmc-send --host=127.0.0.1 -a "ReloadSkin()" &
- ;;
- *) exit $NA
- ;;
-esac
diff --git a/packages/mediacenter/xbmc-frodo/splash/splash.png b/packages/mediacenter/xbmc-frodo/splash/splash.png
deleted file mode 100644
index 6b2897b0a1..0000000000
Binary files a/packages/mediacenter/xbmc-frodo/splash/splash.png and /dev/null differ
diff --git a/packages/mediacenter/xbmc-frodo/splash/splash1.png b/packages/mediacenter/xbmc-frodo/splash/splash1.png
deleted file mode 100644
index ac0aa0052f..0000000000
Binary files a/packages/mediacenter/xbmc-frodo/splash/splash1.png and /dev/null differ
diff --git a/packages/mediacenter/xbmc-frodo/unpack b/packages/mediacenter/xbmc-frodo/unpack
deleted file mode 100755
index 58c11116fd..0000000000
--- a/packages/mediacenter/xbmc-frodo/unpack
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-################################################################################
-# This file is part of OpenELEC - http://www.openelec.tv
-# Copyright (C) 2009-2012 Stephan Raue (stephan@openelec.tv)
-#
-# This Program 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, or (at your option)
-# any later version.
-#
-# This Program 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 OpenELEC.tv; see the file COPYING. If not, write to
-# the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
-# http://www.gnu.org/copyleft/gpl.html
-################################################################################
-
-. config/options $1
-
-echo "### Applying project based patches ###"
-
-for patch in `ls $PROJECT_DIR/$PROJECT/patches/$1`; do
- cat $PROJECT_DIR/$PROJECT/patches/$1/$patch | patch -d \
- `echo $PKG_BUILD | cut -f1 -d\ ` -p1
-done
diff --git a/packages/mediacenter/xbmc-theme-Confluence/meta b/packages/mediacenter/xbmc-theme-Confluence/meta
index 10debe2adc..4995ef08ba 100644
--- a/packages/mediacenter/xbmc-theme-Confluence/meta
+++ b/packages/mediacenter/xbmc-theme-Confluence/meta
@@ -19,7 +19,7 @@
################################################################################
PKG_NAME="xbmc-theme-Confluence"
-PKG_VERSION="11.0.2"
+PKG_VERSION="17c1439"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
diff --git a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-001-add_oe_settings_to_homescreen.patch b/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-001-add_oe_settings_to_homescreen.patch
deleted file mode 100644
index d12175ed71..0000000000
--- a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-001-add_oe_settings_to_homescreen.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- xbmc-theme-Confluence-11.0.1/720p/IncludesHomeMenuItems.xml 2012-03-31 08:37:23.304505434 +0400
-+++ xbmc-theme-Confluence-11.0.1/720p/IncludesHomeMenuItems.patch.xml 2012-03-31 08:39:57.894660377 +0400
-@@ -183,6 +183,11 @@
-
- ActivateWindow(Settings)
-
-+
-+ ButtonHomeSubCommonValues
-+
-+ RunAddon(os.openelec.settings)
-+
-
- ButtonHomeSubCommonValues
-
diff --git a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-801.04-cec-PR887.patch b/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-801.04-cec-PR887.patch
deleted file mode 100644
index ee93a64678..0000000000
--- a/packages/mediacenter/xbmc-theme-Confluence/patches/xbmc-theme-Confluence-11.0.2-801.04-cec-PR887.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From 3e1367b680b26123e9e1aa09f8caf2a932d47572 Mon Sep 17 00:00:00 2001
-From: Lars Op den Kamp
-Date: Tue, 17 Apr 2012 01:57:43 +0200
-Subject: [PATCH 2/2] cec: libCEC 1.6 support and fixes. libCEC 1.6+ is needed
- when using firmware v2 on the CEC adapter, which adds
- wake over CEC * added a new setting to control
- whether to put the TV in standby when the player is put
- in standby. * added some button mappings: all menu
- related buttons -> menu, previous channel -> teletext,
- added support for the channels list on samsung, mapped
- next fav -> menu (when available) * display the
- firmware version in the peripheral manager (if
- available) * handle the new CEC alert callback
- (libCEC 1.6+) * replaced 'Put this PC in standby mode
- when the TV is switched off' with an enum that allows
- the user to chose between 'Ignore', 'Suspend' and
- 'Shutdown' * fixed - crash when changing settings
- without libCEC started. * fixed - range of wake and
- power-off devices * fixed - update the correct
- standby device setting ('standby_devices' not
- 'wake_devices') * fixed - don't get the settings from
- the eeprom, but always use the settings provided in
- xbmc
-
----
- .../720p/DialogPeripheralManager.xml | 4 +-
- configure.in | 2 +-
- language/English/strings.xml | 5 +-
- project/BuildDependencies/scripts/libcec_d.txt | 2 +-
- system/peripherals.xml | 15 +-
- tools/darwin/depends/libcec/Makefile | 2 +-
- xbmc/peripherals/bus/PeripheralBus.cpp | 1 +
- xbmc/peripherals/devices/Peripheral.h | 2 +
- xbmc/peripherals/devices/PeripheralCecAdapter.cpp | 160 ++++++++++++++++----
- xbmc/peripherals/devices/PeripheralCecAdapter.h | 4 +
- 10 files changed, 152 insertions(+), 45 deletions(-)
-
-diff --git a/720p/DialogPeripheralManager.xml b/720p/DialogPeripheralManager.xml
-index 07954d0..5717017 100644
---- a/720p/DialogPeripheralManager.xml
-+++ b/720p/DialogPeripheralManager.xml
-@@ -117,7 +117,7 @@
- 50
- 520
- 20
--
-+
- left
- center
- font12
-@@ -173,7 +173,7 @@
- 50
- 520
- 20
--
-+
- left
- center
- font12
---
-1.7.5.4
-
diff --git a/packages/mediacenter/xbmc/build b/packages/mediacenter/xbmc/build
index 479f94d1cd..e36b24db7e 100755
--- a/packages/mediacenter/xbmc/build
+++ b/packages/mediacenter/xbmc/build
@@ -22,6 +22,9 @@
. config/options $1
+# disable build of GOOM until its fixed
+ XBMC_VIS_GOOM="no"
+
if [ "$DISPLAYSERVER" = "xorg-server" ]; then
XBMC_XORG="--enable-x11 --enable-xrandr"
else
@@ -40,6 +43,12 @@ else
XBMC_OPENGLES="--disable-gles"
fi
+if [ "$SDL_SUPPORT" = yes ]; then
+ XBMC_SDL="--enable-sdl"
+else
+ XBMC_SDL="--disable-sdl"
+fi
+
if [ "$XBMC_SCR_RSXS" = yes ]; then
XBMC_RSXS="--enable-rsxs"
# fix build of RSXS Screensaver support if not using libiconv
@@ -62,6 +71,12 @@ else
XBMC_GOOM="--disable-goom"
fi
+if [ "$ALSA_SUPPORT" = yes ]; then
+ XBMC_ALSA="--enable-alsa"
+else
+ XBMC_ALSA="--disable-alsa"
+fi
+
if [ "$PULSEAUDIO_SUPPORT" = yes ]; then
XBMC_PULSEAUDIO="--enable-pulse"
else
@@ -70,6 +85,9 @@ fi
if [ "$CEC_SUPPORT" = yes ]; then
XBMC_CEC="--enable-libcec"
+ if [ "$OPENMAX" = "bcm2835-driver" ]; then
+ XBMC_CEC="$XBMC_CEC --enable-rpi-cec-api"
+ fi
else
XBMC_CEC="--disable-libcec"
fi
@@ -104,6 +122,18 @@ else
XBMC_DVDCSS="--disable-dvdcss"
fi
+if [ "$ENCODER_LAME" = yes ]; then
+ XBMC_LAMEENC="--enable-libmp3lame"
+else
+ XBMC_LAMEENC="--disable-libmp3lame"
+fi
+
+if [ "$ENCODER_VORBIS" = yes ]; then
+ XBMC_VORBISENC="--enable-libvorbisenc"
+else
+ XBMC_VORBISENC="--disable-libvorbisenc"
+fi
+
if [ "$BLURAY_SUPPORT" = yes ]; then
XBMC_BLURAY="--enable-libbluray"
else
@@ -141,6 +171,18 @@ else
XBMC_WEBSERVER="--disable-webserver"
fi
+if [ "$OPENMAX_SUPPORT" = yes ]; then
+ XBMC_OPENMAX="--enable-openmax"
+ if [ "$OPENMAX" = "bcm2835-driver" ]; then
+ XBMC_PLATFORM_SUPPORT="--with-platform=raspberry-pi"
+ XBMC_PLAYER="--enable-player=omxplayer"
+ CFLAGS="$CFLAGS -I$SYSROOT_PREFIX/usr/include/interface/vcos/pthreads/"
+ CXXFLAGS="$CXXFLAGS -I$SYSROOT_PREFIX/usr/include/interface/vcos/pthreads/"
+ fi
+else
+ XBMC_OPENMAX="--disable-openmax"
+fi
+
if [ "$VDPAU" = yes ]; then
XBMC_VDPAU="--enable-vdpau"
else
@@ -172,7 +214,7 @@ fi
LDFLAGS=`echo $LDFLAGS | sed -e "s|-Wl,--as-needed||"`
# dont build parallel
-# MAKEFLAGS=-j1
+ MAKEFLAGS=-j1
export PYTHON_VERSION="2.7"
export PYTHON_CPPFLAGS="-I$SYSROOT_PREFIX/usr/include/python$PYTHON_VERSION"
@@ -217,13 +259,14 @@ cd $PKG_BUILD
--disable-optimizations \
$XBMC_OPENGL \
$XBMC_OPENGLES \
+ $XBMC_SDL \
+ $XBMC_OPENMAX \
$XBMC_VDPAU \
$XBMC_VAAPI \
$XBMC_CRYSTALHD \
$XBMC_XVBA \
--disable-vdadecoder \
--disable-vtbdecoder \
- --disable-openmax \
--disable-tegra \
--disable-profiling \
$XBMC_JOYSTICK \
@@ -235,13 +278,15 @@ cd $PKG_BUILD
$XBMC_PROJECTM \
$XBMC_XORG \
--disable-ccache \
+ $XBMC_ALSA \
$XBMC_PULSEAUDIO \
--enable-rtmp \
$XBMC_SAMBA \
$XBMC_NFS \
$XBMC_AFP \
+ $XBMC_VORBISENC \
--enable-ffmpeg-libvorbis \
- --enable-lame \
+ $XBMC_LAMEENC \
$XBMC_DVDCSS \
--disable-mid \
--disable-hal \
@@ -256,6 +301,8 @@ cd $PKG_BUILD
--enable-texturepacker --with-texturepacker-root="$ROOT/$TOOLCHAIN" \
--disable-external-libraries \
--enable-external-ffmpeg \
+ $XBMC_PLATFORM_SUPPORT \
+ $XBMC_PLAYER \
# setup default skin inside the sources
sed -i -e "s|skin.confluence|$SKIN_DIR|g" xbmc/settings/Settings.h
diff --git a/packages/mediacenter/xbmc/install b/packages/mediacenter/xbmc/install
index e621426347..90983e8427 100755
--- a/packages/mediacenter/xbmc/install
+++ b/packages/mediacenter/xbmc/install
@@ -41,12 +41,12 @@ cd $PKG_BUILD
find system addons \
-regextype posix-extended -type f \
-not -iregex ".*svn.*|.*win32(dx)?\.vis|.*osx\.vis" \
- -iregex ".*-linux.*|.*\.vis|.*\.xbs" \
+ -iregex ".*-linux.*|.*-arm.*|.*\.vis|.*\.xbs" \
-exec install -D "{}" $ROOT/$INSTALL/usr/lib/xbmc/"{}" ";"
find addons language media sounds userdata system \
-regextype posix-extended -type f \
- -not -iregex ".*-linux.*|.*\.vis|.*\.xbs|.*svn.*|.*\.orig|.*\.so|.*\.dll|.*\.pyd|.*python|.*\.zlib|.*\.conf" \
+ -not -iregex ".*-linux.*|.*-arm.*|.*\.vis|.*\.xbs|.*svn.*|.*\.orig|.*\.so|.*\.dll|.*\.pyd|.*python|.*\.zlib|.*\.conf" \
-exec install -D -m 0644 "{}" $ROOT/$INSTALL/usr/share/xbmc/"{}" ";"
cd -
diff --git a/packages/mediacenter/xbmc/meta b/packages/mediacenter/xbmc/meta
index 9691da35bc..5887ddec1e 100644
--- a/packages/mediacenter/xbmc/meta
+++ b/packages/mediacenter/xbmc/meta
@@ -19,14 +19,14 @@
################################################################################
PKG_NAME="xbmc"
-PKG_VERSION="11.0.2"
+PKG_VERSION="17c1439"
PKG_REV="1"
PKG_ARCH="any"
PKG_LICENSE="GPL"
PKG_SITE="http://www.xbmc.org"
PKG_URL="$DISTRO_SRC/$PKG_NAME-$PKG_VERSION.tar.xz"
-PKG_DEPENDS="boost Python zlib bzip2 systemd pcre ffmpeg alsa-lib libass curl libssh rtmpdump fontconfig tinyxml freetype libmad libogg libvorbis libmodplug faad2 flac lame libmpeg2 SDL SDL_mixer SDL_image yajl sqlite alsa bc xbmc-addon-settings"
-PKG_BUILD_DEPENDS="toolchain boost Python zlib bzip2 systemd lzo pcre alsa-lib ffmpeg libass enca curl libssh rtmpdump fontconfig fribidi tinyxml libjpeg-turbo libpng tiff freetype jasper libmad libsamplerate libogg libvorbis libcdio libmodplug faad2 flac lame libmpeg2 SDL SDL_mixer SDL_image yajl sqlite mysql"
+PKG_DEPENDS="boost Python zlib bzip2 systemd pcre ffmpeg libass curl libssh rtmpdump fontconfig tinyxml freetype libmad libogg libmodplug faad2 flac libmpeg2 taglib yajl sqlite bc xbmc-addon-settings"
+PKG_BUILD_DEPENDS="toolchain boost Python zlib bzip2 systemd lzo pcre swig ffmpeg libass enca curl libssh rtmpdump fontconfig fribidi tinyxml libjpeg-turbo libpng tiff freetype jasper libmad libsamplerate libogg libcdio libmodplug faad2 flac libmpeg2 taglib yajl sqlite mysql"
PKG_PRIORITY="optional"
PKG_SECTION="mediacenter"
PKG_SHORTDESC="xbmc: XBMC Mediacenter"
@@ -43,8 +43,9 @@ PKG_AUTORECONF="no"
PKG_DEPENDS="$PKG_DEPENDS simplejson"
# various PVR clients
- PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr xbmc-addon-njoy"
- PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr xbmc-addon-vuplus"
+ PKG_DEPENDS="$PKG_DEPENDS xbmc-pvr-addons"
+ PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-vuplus"
+ PKG_DEPENDS="$PKG_DEPENDS xbmc-addon-xvdr"
if [ "$DISPLAYSERVER" = "xorg-server" ]; then
# for libX11 support
@@ -54,6 +55,10 @@ if [ "$DISPLAYSERVER" = "xorg-server" ]; then
# for libXrandr support
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libXrandr"
PKG_DEPENDS="$PKG_DEPENDS libXrandr"
+
+ # for SDL support
+ PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS SDL SDL_image"
+ PKG_DEPENDS="$PKG_DEPENDS SDL SDL_image"
fi
if [ "$OPENGL_SUPPORT" = yes ]; then
@@ -72,6 +77,11 @@ fi
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS dbus"
PKG_DEPENDS="$PKG_DEPENDS dbus"
+if [ "$ALSA_SUPPORT" = yes ]; then
+ PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS alsa-lib"
+ PKG_DEPENDS="$PKG_DEPENDS alsa alsa-lib"
+fi
+
if [ "$PULSEAUDIO_SUPPORT" = yes ]; then
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS pulseaudio"
PKG_DEPENDS="$PKG_DEPENDS pulseaudio"
@@ -92,6 +102,16 @@ if [ "$FAAC_SUPPORT" = yes ]; then
PKG_DEPENDS="$PKG_DEPENDS faac"
fi
+if [ "$ENCODER_LAME" = yes ]; then
+ PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS lame"
+ PKG_DEPENDS="$PKG_DEPENDS lame"
+fi
+
+if [ "$ENCODER_VORBIS" = yes ]; then
+ PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libvorbis"
+ PKG_DEPENDS="$PKG_DEPENDS libvorbis"
+fi
+
if [ "$BLURAY_SUPPORT" = yes ]; then
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libbluray"
PKG_DEPENDS="$PKG_DEPENDS libbluray"
@@ -131,6 +151,11 @@ if [ "$WEBSERVER" = yes ]; then
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libmicrohttpd"
fi
+if [ "$OPENMAX_SUPPORT" = yes ]; then
+ PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS $OPENMAX"
+ PKG_DEPENDS="$PKG_DEPENDS $OPENMAX"
+fi
+
if [ "$VDPAU" = yes ]; then
PKG_BUILD_DEPENDS="$PKG_BUILD_DEPENDS libvdpau"
PKG_DEPENDS="$PKG_DEPENDS libvdpau"
diff --git a/packages/mediacenter/xbmc/patches/rename.sh b/packages/mediacenter/xbmc/patches/rename.sh
index 35c8994035..21b155f7be 100755
--- a/packages/mediacenter/xbmc/patches/rename.sh
+++ b/packages/mediacenter/xbmc/patches/rename.sh
@@ -20,7 +20,6 @@
# http://www.gnu.org/copyleft/gpl.html
################################################################################
-
for i in `ls xbmc-*.patch`; do
mv $i `echo $i | sed "s,$1,$2,g"`
done
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch
deleted file mode 100644
index c013e0ae3a..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-001-add_support_to_specify_GIT_REV-0.1.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff -Naur xbmc-9389dc8/configure.in xbmc-9389dc8.patch/configure.in
---- xbmc-9389dc8/configure.in 2011-09-01 17:21:47.000000000 +0200
-+++ xbmc-9389dc8.patch/configure.in 2011-09-01 23:30:40.419399392 +0200
-@@ -428,6 +428,14 @@
- esac
- AC_SUBST([ARCH])
-
-+AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
-+if test "$HAVE_GIT" = "yes" -a "$GIT_REV" = ""; then
-+ GIT_REV=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h %ci" HEAD | awk '{gsub("-", "");print $2"-"$1}')
-+elif test "$GIT_REV" = ""; then
-+ GIT_REV="Unknown"
-+fi
-+final_message="$final_message\n git Rev.:\t${GIT_REV}"
-+
- # platform debug flags
- if test "$use_debug" = "yes"; then
- final_message="$final_message\n Debugging:\tYes"
-@@ -1177,7 +1185,6 @@
- fi
- fi
-
--AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
-
- # Checks for header files.
- AC_HEADER_DIRENT
-@@ -1408,12 +1415,6 @@
- final_message="$final_message\n Avahi:\tNo"
- fi
-
--if test "$HAVE_GIT" = "yes"; then
-- GIT_REV=$(git --no-pager log --abbrev=7 -n 1 --pretty=format:"%h %ci" HEAD | awk '{gsub("-", "");print $2"-"$1}')
--fi
--if test "$GIT_REV" = ""; then
-- GIT_REV="Unknown"
--fi
- if test "$host_vendor" = "apple"; then
- echo "#define GIT_REV \"$GIT_REV\"" > git_revision.h
- else
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch
deleted file mode 100644
index 5e76acefe4..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-303-fix_libdvd_xFLAGS-0.1.patch
+++ /dev/null
@@ -1,119 +0,0 @@
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdcss/src/libdvdcss.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdcss/src/libdvdcss.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdcss/src/libdvdcss.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdcss/src/libdvdcss.pc.in 2011-04-25 05:01:20.091837122 +0200
-@@ -6,5 +6,5 @@
- Name: libdvdcss
- Description: DVD access and decryption library.
- Version: @VERSION@
--Libs: -L${libdir} -ldvdcss
--Cflags: -I{includedir} -I${includedir}/@PACKAGE@
-+Libs: -ldvdcss
-+Cflags: -I.
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config2.sh 2011-04-25 05:01:20.549828701 +0200
-@@ -56,17 +56,17 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I$prefix/include $dvdread_cflags $extracflags $threadcflags
-+ echo $dvdread_cflags $extracflags $threadcflags
- fi
-
- if test "$echo_minicflags" = "yes"; then
-- echo -I$prefix/include -I$prefix/include/dvdnav $extracflags $threadcflags
-+ echo $extracflags $threadcflags
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L$libdir -ldvdnav $dvdread_libs $threadlib
-+ echo -ldvdnav $dvdread_libs $threadlib
- fi
-
- if test "$echo_minilibs" = "yes"; then
-- echo -L$libdir -ldvdnavmini $threadlib
-+ echo -ldvdnavmini $threadlib
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav-config.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav-config.in 2011-04-25 05:01:20.624827321 +0200
-@@ -76,13 +76,13 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I@includedir@ -I@includedir@/libdvdread @THREAD_CFLAGS@
-+ echo @THREAD_CFLAGS@
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L@libdir@ -ldvdnav -ldvdread @THREAD_LIBS@
-+ echo -ldvdnav -ldvdread @THREAD_LIBS@
- fi
-
- if test "$echo_minilibs" = "yes"; then
-- echo -L@libdir@ -ldvdnavmini @THREAD_LIBS@
-+ echo -ldvdnavmini @THREAD_LIBS@
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnavmini.pc.in 2011-04-25 05:01:21.042819641 +0200
-@@ -7,5 +7,5 @@
- Description: DVD Navigation mini library
- Version: @VERSION@
-
--Cflags: -I${includedir} @DVDREAD_CFLAGS@ @THREAD_CFLAGS@
--Libs: -L${libdir} -ldvdnav @THREAD_LIBS@
-+Cflags: @DVDREAD_CFLAGS@ @THREAD_CFLAGS@
-+Libs: -ldvdnav @THREAD_LIBS@
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdnav/misc/dvdnav.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdnav/misc/dvdnav.pc.in 2011-04-25 05:01:21.262815601 +0200
-@@ -8,5 +8,5 @@
- Version: @VERSION@
-
- Requires.private: dvdread >= 4.1.2
--Cflags: -I${includedir} @THREAD_CFLAGS@
--Libs: -L${libdir} -ldvdnav @THREAD_LIBS@
-+Cflags: @THREAD_CFLAGS@
-+Libs: -ldvdnav @THREAD_LIBS@
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.in 2011-04-25 05:01:21.278815307 +0200
-@@ -72,9 +72,9 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I@includedir@
-+ echo ""
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L@libdir@ -ldvdread
-+ echo -ldvdread
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.sh xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.sh
---- xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread-config.sh 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread-config.sh 2011-04-25 05:01:21.278815307 +0200
-@@ -48,9 +48,9 @@
- fi
-
- if test "$echo_cflags" = "yes"; then
-- echo -I$prefix/include $extracflags
-+ echo $extracflags
- fi
-
- if test "$echo_libs" = "yes"; then
-- echo -L$libdir $dvdreadlib
-+ echo $dvdreadlib
- fi
-diff -Naur xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread.pc.in xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread.pc.in
---- xbmc-pvr-3513480/lib/libdvd/libdvdread/misc/dvdread.pc.in 2011-04-25 02:36:42.000000000 +0200
-+++ xbmc-pvr-3513480.patch/lib/libdvd/libdvdread/misc/dvdread.pc.in 2011-04-25 05:01:21.279815289 +0200
-@@ -7,5 +7,5 @@
- Description: Low level DVD access library
- Version: @VERSION@
-
--Cflags: -I${includedir}
--Libs: -L${libdir} -ldvdread
-+Cflags: -I.
-+Libs: -ldvdread
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-311-fix_rsxs_build-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-311-fix_rsxs_build-0.1.patch
deleted file mode 100644
index fe0ee49cab..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-311-fix_rsxs_build-0.1.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-dab646e/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h xbmc-dab646e.patch/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h
---- xbmc-dab646e/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h 2011-09-27 15:56:19.000000000 +0200
-+++ xbmc-dab646e.patch/xbmc/screensavers/rsxs-0.9/lib/argp-namefrob.h 2011-10-16 02:13:13.805433847 +0200
-@@ -17,7 +17,7 @@
- with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-
--#if !_LIBC
-+#if 0
- /* This code is written for inclusion in gnu-libc, and uses names in the
- namespace reserved for libc. If we're not compiling in libc, define those
- names to be the normal ones instead. */
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-321-texturepacker-hostflags-and-rework.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-321-texturepacker-hostflags-and-rework.patch
deleted file mode 100644
index 507334d2e2..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-321-texturepacker-hostflags-and-rework.patch
+++ /dev/null
@@ -1,199 +0,0 @@
-diff -Naur xbmc-pvr-11.0.1/configure.in xbmc-pvr-11.0.1.patch/configure.in
---- xbmc-pvr-11.0.1/configure.in 2012-03-27 17:55:54.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/configure.in 2012-06-19 04:44:55.985036378 +0200
-@@ -385,6 +385,12 @@
- [use_texturepacker=$enableval],
- [use_texturepacker=auto])
-
-+AC_ARG_WITH([texturepacker-root],
-+ [AS_HELP_STRING([--with-texturepacker-root],
-+ [root dir to search for librarys and includes if building native TexturePacker (default is \$prefix)])],
-+ [use_texturepacker_root=$withval],
-+ [use_texturepacker_root=$prefix])
-+
- AC_ARG_WITH([lirc-device],
- [AS_HELP_STRING([--with-lirc-device=file],
- [specify the default LIRC device (default is /dev/lircd)])],
-@@ -466,8 +472,7 @@
- use_cpu=cortex-a8
- check_sdl_arch=[`file /opt/local/lib/libSDL_image.dylib | awk '{V=7; print $V}'`]
- if test "x$check_sdl_arch" = "xi386"; then
-- use_texturepacker_native=yes
-- USE_TEXTUREPACKER_NATIVE_ROOT="/opt/local"
-+ use_texturepacker_root="/opt/local"
- else
- use_texturepacker=no
- fi
-@@ -484,8 +489,6 @@
- *86-apple-darwin*)
- use_joystick=no
- use_vtbdecoder=no
-- use_texturepacker_native=yes
-- USE_TEXTUREPACKER_NATIVE_ROOT="$prefix"
- ARCH="x86-osx"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
- ;;
-@@ -1649,17 +1652,17 @@
-
- USE_TEXTUREPACKER_NATIVE=0
- if test "x$use_texturepacker" != "xno"; then
-- final_message="$final_message\n TexturePacker:Yes"
-- USE_TEXTUREPACKER=1
-- if test "x$use_texturepacker_native" = "xyes"; then
-+ if test "x$cross_compiling" = "xyes"; then
- USE_TEXTUREPACKER_NATIVE=1
-- if [[ ! -d "$USE_TEXTUREPACKER_NATIVE_ROOT" ]]; then
-- USE_TEXTUREPACKER_NATIVE_ROOT=
-- fi
-+ USE_TEXTUREPACKER_NATIVE_ROOT="$use_texturepacker_root"
-+ final_message="$final_message\n TexturePacker:Native ($USE_TEXTUREPACKER_NATIVE_ROOT)"
-+ else
-+ USE_TEXTUREPACKER=1
-+ final_message="$final_message\n TexturePacker:Yes"
- fi
- else
-- final_message="$final_message\n TexturePacker:No"
- USE_TEXTUREPACKER=0
-+ final_message="$final_message\n TexturePacker:No"
- fi
-
- if test "$use_mid" = "yes"; then
-diff -Naur xbmc-pvr-11.0.1/lib/libsquish/Makefile.in xbmc-pvr-11.0.1.patch/lib/libsquish/Makefile.in
---- xbmc-pvr-11.0.1/lib/libsquish/Makefile.in 2012-03-27 17:55:41.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/libsquish/Makefile.in 2012-06-19 02:45:32.926185206 +0200
-@@ -1,6 +1,6 @@
- ARCH=@ARCH@
-
--SRCS= \
-+SRCS = \
- alpha.cpp \
- clusterfit.cpp \
- colourblock.cpp \
-@@ -11,27 +11,30 @@
- singlecolourfit.cpp \
- squish.cpp
-
--CXXFLAGS+=-I.
-+LIB = libsquish.a
-+NATIVE_LIB = libsquish-native.so
-+CLEAN_FILES += $(NATIVE_LIB)
-+
-+HOST_CXX ?= g++
-+CXXFLAGS += -I.
-+HOST_CXXFLAGS += -I.
-+
- ifeq ($(findstring powerpc,$(ARCH)),powerpc)
-- CXXFLAGS+=-DSQUISH_USE_ALTIVEC=1 -maltivec
-+ CXXFLAGS += -DSQUISH_USE_ALTIVEC=1 -maltivec
-+ HOST_CXXFLAGS += -DSQUISH_USE_ALTIVEC=1 -maltivec
- else ifeq ($(findstring x86,$(ARCH)), x86)
-- CXXFLAGS+=-DSQUISH_USE_SSE=2 -msse2
-+ CXXFLAGS += -DSQUISH_USE_SSE=2 -msse2
-+ HOST_CXXFLAGS += -DSQUISH_USE_SSE=2 -msse2
- endif
-
--LIB=libsquish.a
--
--ifeq (@USE_TEXTUREPACKER_NATIVE@,1)
--NATIVE_LIB=libsquish-native.so
--CLEAN_FILES+=$(NATIVE_LIB)
-+$(LIB): $(SRCS)
-
--all: $(LIB) $(NATIVE_LIB)
- # TexturePacker links to libsquish and needs to run on build system, so make a native flavor.
- $(NATIVE_LIB): $(SRCS)
- ifeq ($(findstring osx,$(ARCH)),osx)
-- g++ -m32 -DSQUISH_USE_SSE=2 -msse2 -I. $(SRCS) -dynamiclib -install_name `pwd`/libsquish-native.so -o $@
-+ $(HOST_CXX) -m32 $(HOST_CXXFLAGS) $(SRCS) -dynamiclib -install_name `pwd`/libsquish-native.so -o $@
- else
-- g++ -DSQUISH_USE_SSE=2 -msse2 -I. $(SRCS) -shared -fPIC -Wl,-soname,`pwd`/libsquish-native.so -o $@
--endif
-+ $(HOST_CXX) $(HOST_CXXFLAGS) $(SRCS) -shared -fPIC -Wl,-soname,`pwd`/libsquish-native.so -o $@
- endif
-
- include ../../Makefile.include
-diff -Naur xbmc-pvr-11.0.1/tools/TexturePacker/Makefile.in xbmc-pvr-11.0.1.patch/tools/TexturePacker/Makefile.in
---- xbmc-pvr-11.0.1/tools/TexturePacker/Makefile.in 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/tools/TexturePacker/Makefile.in 2012-06-19 04:47:54.700638167 +0200
-@@ -1,47 +1,52 @@
--DEFINES += -D_LINUX -DUSE_LZO_PACKING
-+DEFINES += -D_LINUX -DUSE_LZO_PACKING
- ifneq ($(or $(findstring powerpc,@ARCH@),$(findstring ppc, @ARCH@)),)
--DEFINES += -DHOST_BIGENDIAN
-+DEFINES += -DHOST_BIGENDIAN
- endif
-
--CXXFLAGS+= \
-- -I. \
-- -I@abs_top_srcdir@/lib \
-- -I@abs_top_srcdir@/xbmc \
-- -I@abs_top_srcdir@/xbmc/linux
--
--ifeq (@USE_TEXTUREPACKER_NATIVE@,1)
--NATIVE_ROOT_PATH=@USE_TEXTUREPACKER_NATIVE_ROOT@
--ifdef NATIVE_ROOT_PATH
--ifeq ($(findstring osx,@ARCH@),osx)
--CXXFLAGS+= -m32
--endif
--CXXFLAGS+= -I$(NATIVE_ROOT_PATH)/include
--LIBS += -L$(NATIVE_ROOT_PATH)/lib
--endif
--LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish-native
--else
--LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish
--endif
--
--LIBS += -lSDL_image -lSDL -llzo2
--
--SRCS = \
-+SRCS = \
- md5.cpp \
- SDL_anigif.cpp \
- XBTFWriter.cpp \
- XBMCTex.cpp \
- @abs_top_srcdir@/xbmc/guilib/XBTF.cpp
-
--
--TARGET = TexturePacker
--CLEAN_FILES=$(TARGET)
-+TARGET = TexturePacker
-+CLEAN_FILES = $(TARGET)
-
- all: $(TARGET)
-
-+HOST_CXX ?= g++
-+HOST_ROOT_PATH = @USE_TEXTUREPACKER_NATIVE_ROOT@
-+
-+LIBS += -lSDL_image -lSDL -llzo2
-+LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish
-+HOST_LIBS += -L$(HOST_ROOT_PATH)/lib -lSDL_image -lSDL -llzo2
-+HOST_LIBS += -L@abs_top_srcdir@/lib/libsquish -lsquish-native
-+
-+CXXFLAGS += \
-+ -I. \
-+ -I@abs_top_srcdir@/lib \
-+ -I@abs_top_srcdir@/xbmc \
-+ -I@abs_top_srcdir@/xbmc/linux
-+
-+HOST_CXXFLAGS += \
-+ -I. \
-+ -I@abs_top_srcdir@/lib \
-+ -I@abs_top_srcdir@/xbmc \
-+ -I@abs_top_srcdir@/xbmc/linux \
-+ -I$(HOST_ROOT_PATH)/include
-+
-+ifeq ($(findstring osx,@ARCH@),osx)
-+CXXFLAGS += -m32
-+HOST_CXXFLAGS += -m32
-+endif
-+
- ifeq (@USE_TEXTUREPACKER_NATIVE@,1)
- # TexturePacker run native on build system, build it with native tools
- $(TARGET): $(SRCS)
-- g++ $(DEFINES) $(CXXFLAGS) $(SRCS) $(LIBS) -o $(TARGET)
-+ make -C @abs_top_srcdir@/lib/libsquish libsquish-native.so
-+ $(HOST_CXX) $(DEFINES) $(HOST_CXXFLAGS) $(SRCS) $(HOST_LIBS) -o $(TARGET)
-+
- clean:
- rm -f $(TARGET)
- else
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch
deleted file mode 100644
index 63b04cb3e0..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-331-fix_playpause_problem_ticket_7338-0.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/xbmc/Application.cpp xbmc-10.1-Dharma.patch/xbmc/Application.cpp
---- xbmc-10.1-Dharma/xbmc/Application.cpp 2011-03-08 02:49:14.000000000 +0100
-+++ xbmc-10.1-Dharma.patch/xbmc/Application.cpp 2011-05-06 01:41:52.853741840 +0200
-@@ -2515,8 +2515,8 @@
- if (!m_pPlayer->IsPaused())
- { // unpaused - set the playspeed back to normal
- SetPlaySpeed(1);
-+ g_audioManager.Enable(m_pPlayer->IsPaused() && !g_audioContext.IsPassthroughActive());
- }
-- g_audioManager.Enable(m_pPlayer->IsPaused() && !g_audioContext.IsPassthroughActive());
- return true;
- }
- if (!m_pPlayer->IsPaused())
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch
deleted file mode 100644
index b8f5b8afcf..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-402-enable_yasm_in_ffmpeg-0.1.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -Naur xbmc-pvr-3513480/configure.in xbmc-pvr-3513480.patch/configure.in
---- xbmc-pvr-3513480/configure.in 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/configure.in 2011-04-25 05:14:49.220848143 +0200
-@@ -885,6 +885,9 @@
- AC_MSG_NOTICE($external_ffmpeg_disabled)
- USE_EXTERNAL_FFMPEG=0
- AC_DEFINE([PIX_FMT_VDPAU_MPEG4_IN_AVUTIL], [1], [Whether AVUtil defines PIX_FMT_VDPAU_MPEG4.])
-+
-+ # check for yasm
-+ AC_CHECK_PROG(HAVE_YASM,yasm,"yes","no",)
- fi
-
- # Python
-@@ -1547,6 +1550,7 @@
- `if test "$use_arch" != "no"; then echo --arch=$use_arch; fi`\
- `if test "$use_cpu" != "no"; then echo --cpu=$use_cpu; fi`\
- --target-os=$(tolower $(uname -s)) \
-+ `if test "$HAVE_YASM" = "yes"; then echo --enable-yasm; fi` \
- --disable-muxers \
- --enable-muxer=spdif \
- --enable-muxer=adts \
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-404-add_lame_check-0.6.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-404-add_lame_check-0.6.patch
deleted file mode 100644
index a459219108..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-404-add_lame_check-0.6.patch
+++ /dev/null
@@ -1,125 +0,0 @@
-diff -Naur xbmc-pvr-3513480/configure.in xbmc-pvr-3513480.patch/configure.in
---- xbmc-pvr-3513480/configure.in 2011-04-25 05:46:35.000000000 +0200
-+++ xbmc-pvr-3513480.patch/configure.in 2011-04-25 05:50:02.982401390 +0200
-@@ -72,6 +72,8 @@
- rsxs_disabled="== RSXS disabled. =="
- pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
- pulse_disabled="== PulseAudio support manually disabled. =="
-+lame_not_found="== Could not find libmp3lame. LAME support disabled. =="
-+lame_disabled="== LAME support manually disabled. =="
- dvdcss_enabled="== DVDCSS support enabled. =="
- dvdcss_disabled="== DVDCSS support disabled. =="
- hal_not_found="== Could not find hal. HAL support disabled. =="
-@@ -244,6 +246,12 @@
- [use_ffmpeg_libvorbis=$enableval],
- [use_ffmpeg_libvorbis=no])
-
-+AC_ARG_ENABLE([lame],
-+ [AS_HELP_STRING([--enable-lame],
-+ [enable lame support (default is yes)])],
-+ [use_lame=$enableval],
-+ [use_lame=yes])
-+
- AC_ARG_ENABLE([dvdcss],
- [AS_HELP_STRING([--enable-dvdcss],
- [enable DVDCSS support (default is yes)])],
-@@ -758,6 +766,20 @@
- USE_PULSE=0
- fi
-
-+# LAME
-+if test "$use_lame" = "yes"; then
-+ AC_CHECK_LIB([mp3lame], [main],
-+ AC_DEFINE([HAVE_LIBMP3LAME], [1], [Define to 1 if you have the 'libmp3lame' library (-lmp3lame).]),
-+ use_lame=no;AC_MSG_RESULT($lame_not_found))
-+else
-+ AC_MSG_RESULT($lame_disabled)
-+fi
-+if test "$use_lame" = "yes"; then
-+ AC_SUBST([HAVE_LIBMP3LAME], 1)
-+else
-+ AC_SUBST([HAVE_LIBMP3LAME], 0)
-+fi
-+
- # HAL
- if test "$host_vendor" = "apple" ; then
- use_hal="no"
-@@ -1311,6 +1333,12 @@
- final_message="$final_message\n HAL Support:\tNo"
- fi
-
-+if test "$use_lame" = "yes"; then
-+ final_message="$final_message\n LAME:\t\tYes"
-+else
-+ final_message="$final_message\n LAME:\t\tNo"
-+fi
-+
- # DVDCSS
- if test "$use_dvdcss" = "yes"; then
- AC_MSG_NOTICE($dvdcss_enabled)
-diff -Naur xbmc-pvr-3513480/configure.in.orig xbmc-pvr-3513480.patch/configure.in.orig
-diff -Naur xbmc-pvr-3513480/Makefile.in.orig xbmc-pvr-3513480.patch/Makefile.in.orig
-diff -Naur xbmc-pvr-3513480/xbmc/cdrip/CDDARipper.cpp xbmc-pvr-3513480.patch/xbmc/cdrip/CDDARipper.cpp
---- xbmc-pvr-3513480/xbmc/cdrip/CDDARipper.cpp 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/xbmc/cdrip/CDDARipper.cpp 2011-04-25 05:48:10.487548571 +0200
-@@ -27,7 +27,11 @@
- #include "CDDAReader.h"
- #include "utils/StringUtils.h"
- #include "Util.h"
-+
-+#ifdef HAVE_LIBMP3LAME
- #include "EncoderLame.h"
-+#endif
-+
- #include "EncoderWav.h"
- #include "EncoderVorbis.h"
- #include "EncoderFFmpeg.h"
-@@ -78,9 +82,16 @@
- case CDDARIP_ENCODER_FLAC:
- m_pEncoder = new CEncoderFlac();
- break;
-- default:
-+#ifdef HAVE_LIBMP3LAME
-+ case CDDARIP_ENCODER_LAME:
- m_pEncoder = new CEncoderLame();
- break;
-+#else
-+ default:
-+ CLog::Log(LOGERROR,"invalid encoder selected");
-+ return false;
-+ break;
-+#endif
- }
-
- // we have to set the tags before we init the Encoder
-diff -Naur xbmc-pvr-3513480/xbmc/cdrip/Makefile.in xbmc-pvr-3513480.patch/xbmc/cdrip/Makefile.in
---- xbmc-pvr-3513480/xbmc/cdrip/Makefile.in 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/xbmc/cdrip/Makefile.in 2011-04-25 05:51:13.013064387 +0200
-@@ -3,10 +3,13 @@
- Encoder.cpp \
- EncoderFFmpeg.cpp \
- EncoderFlac.cpp \
-- EncoderLame.cpp \
- EncoderVorbis.cpp \
- EncoderWav.cpp \
-
-+ifeq (@HAVE_LIBMP3LAME@,1)
-+ SRCS+=EncoderLame.cpp
-+endif
-+
- LIB=cdrip.a
-
- include @abs_top_srcdir@/Makefile.include
-diff -Naur xbmc-pvr-3513480/xbmc/settings/GUISettings.cpp xbmc-pvr-3513480.patch/xbmc/settings/GUISettings.cpp
---- xbmc-pvr-3513480/xbmc/settings/GUISettings.cpp 2011-04-25 05:47:12.000000000 +0200
-+++ xbmc-pvr-3513480.patch/xbmc/settings/GUISettings.cpp 2011-04-25 05:48:47.956833472 +0200
-@@ -324,7 +324,9 @@
- AddPath(acd,"audiocds.recordingpath",20000,"select writable folder",BUTTON_CONTROL_PATH_INPUT,false,657);
- AddString(acd, "audiocds.trackpathformat", 13307, "%A - %B/[%N. ][%A - ]%T", EDIT_CONTROL_INPUT, false, 16016);
- map encoders;
-+#ifdef HAVE_LIBMP3LAME
- encoders.insert(make_pair(34000,CDDARIP_ENCODER_LAME));
-+#endif
- encoders.insert(make_pair(34001,CDDARIP_ENCODER_VORBIS));
- encoders.insert(make_pair(34002,CDDARIP_ENCODER_WAV));
- encoders.insert(make_pair(34005,CDDARIP_ENCODER_FLAC));
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
deleted file mode 100644
index 821c1cc7bd..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-408-enable_PYTHONOPTIMIZE_with_external_Python-0.1.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff -Naur xbmc-a3c804b/xbmc/interfaces/python/XBPython.cpp xbmc-a3c804b.patch/xbmc/interfaces/python/XBPython.cpp
---- xbmc-a3c804b/xbmc/interfaces/python/XBPython.cpp 2011-08-17 23:40:00.000000000 +0200
-+++ xbmc-a3c804b.patch/xbmc/interfaces/python/XBPython.cpp 2011-08-18 03:50:49.652475572 +0200
-@@ -335,11 +335,9 @@
- // at http://docs.python.org/using/cmdline.html#environment-variables
-
- #if !defined(_WIN32)
-- /* PYTHONOPTIMIZE is set off intentionally when using external Python.
-- Reason for this is because we cannot be sure what version of Python
-- was used to compile the various Python object files (i.e. .pyo,
-- .pyc, etc.). */
-- // check if we are running as real xbmc.app or just binary
-+ // Required for python to find optimized code (pyo) files
-+ setenv("PYTHONOPTIMIZE", "1", 1);
-+ // check if we are running as real xbmc.app or just binary
- if (!CUtil::GetFrameworksPath(true).IsEmpty())
- {
- // using external python, it's build looking for xxx/lib/python2.6
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-452-change_lcd_content-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-452-change_lcd_content-0.1.patch
deleted file mode 100644
index 0427b534f9..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-452-change_lcd_content-0.1.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-pvr-3513480/userdata/LCD.xml xbmc-pvr-3513480.patch/userdata/LCD.xml
---- xbmc-pvr-3513480/userdata/LCD.xml 2011-04-25 02:36:33.000000000 +0200
-+++ xbmc-pvr-3513480.patch/userdata/LCD.xml 2011-04-25 05:27:34.956125133 +0200
-@@ -21,7 +21,7 @@
- Freemem: $INFO[System.FreeMemory]
-
-
-- XBMC running...
-+ *** OpenELEC ***
- $INFO[System.Time] $INFO[System.Date]
- Freemem: $INFO[System.FreeMemory]
- $INFO[System.ScreenWidth]x$INFO[System.ScreenHeight] $INFO[System.ScreenMode]
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch
deleted file mode 100644
index 5b32c0cce7..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-453-add_openelec.tv_RSS_news-0.1.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/userdata/RssFeeds.xml xbmc-10.1-Dharma.patch/userdata/RssFeeds.xml
---- xbmc-10.1-Dharma/userdata/RssFeeds.xml 2011-03-08 02:49:24.000000000 +0100
-+++ xbmc-10.1-Dharma.patch/userdata/RssFeeds.xml 2011-06-14 17:07:08.450880123 +0200
-@@ -3,6 +3,7 @@
-
-
-
-+ http://openelec.tv/news?format=feed&type=rss
- http://feeds.feedburner.com/xbmc
-
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-454-disable_backslash-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-454-disable_backslash-0.1.patch
deleted file mode 100644
index 0888920258..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-454-disable_backslash-0.1.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-30a9070/system/keymaps/keyboard.xml xbmc-30a9070.patch/system/keymaps/keyboard.xml
---- xbmc-30a9070/system/keymaps/keyboard.xml 2011-07-28 06:20:13.000000000 +0200
-+++ xbmc-30a9070.patch/system/keymaps/keyboard.xml 2011-07-28 09:39:57.210973380 +0200
-@@ -90,7 +90,7 @@
- Number7
- Number8
- Number9
-- ToggleFullScreen
-+
- FirstPage
- LastPage
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-457-fix_connection_check-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-457-fix_connection_check-0.1.patch
deleted file mode 100644
index f4982ec635..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-457-fix_connection_check-0.1.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/xbmc/FileSystem/FileCurl.cpp xbmc-10.1-Dharma.patch/xbmc/FileSystem/FileCurl.cpp
---- xbmc-10.1-Dharma/xbmc/filesystem/FileCurl.cpp 2011-03-08 02:49:14.000000000 +0100
-+++ xbmc-10.1-Dharma.patch/xbmc/filesystem/FileCurl.cpp 2011-10-17 19:21:04.180783870 +0200
-@@ -803,9 +803,9 @@
- // Detect whether we are "online" or not! Very simple and dirty!
- bool CFileCurl::IsInternet(bool checkDNS /* = true */)
- {
-- CStdString strURL = "http://www.google.com";
-+ CStdString strURL = "http://www.openelec.tv";
- if (!checkDNS)
-- strURL = "http://74.125.19.103"; // www.google.com ip
-+ strURL = "http://212.101.13.10"; // www.openelec.tv ip
-
- bool found = Exists(strURL);
- Close();
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-463-add_remote_devinput-0.1.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-463-add_remote_devinput-0.1.patch
deleted file mode 100644
index 85d635b61b..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-463-add_remote_devinput-0.1.patch
+++ /dev/null
@@ -1,71 +0,0 @@
-diff -Naur xbmc-10.1-Dharma/system/Lircmap.xml xbmc-10.1-Dharma.patch/system/Lircmap.xml
---- xbmc-10.1-Dharma/system/Lircmap.xml 2011-06-18 01:43:43.132101246 +0200
-+++ xbmc-10.1-Dharma.patch/system/Lircmap.xml 2011-06-18 01:44:53.777025290 +0200
-@@ -365,7 +365,6 @@
-
-
- cx23885_remote
-- devinput
- KEY_LEFT
- KEY_RIGHT
- KEY_UP
-@@ -452,4 +451,59 @@
- yellow
- blue
-
-+
-+
-+ KEY_LEFT
-+ KEY_RIGHT
-+ KEY_UP
-+ KEY_DOWN
-+
-+ KEY_ENTER
-+ KEY_DELETE
-+ KEY_PROG1
-+ KEY_EXIT
-+ KEY_RECORD
-+ KEY_PLAY
-+ KEY_PAUSE
-+ KEY_STOP
-+ KEY_FASTFORWARD
-+ KEY_REWIND
-+ KEY_VOLUMEUP
-+ KEY_VOLUMEDOWN
-+ KEY_CHANNELUP
-+ KEY_CHANNELDOWN
-+ KEY_NEXT
-+ KEY_PREVIOUS
-+ KEY_EPG
-+ KEY_SUBTITLE
-+ KEY_LANGUAGE
-+ KEY_INFO
-+ KEY_ZOOM
-+ KEY_MUTE
-+ KEY_POWER
-+ KEY_EJECT
-+
-+
-+ KEY_VIDEO
-+ KEY_AUDIO
-+ KEY_CAMERA
-+ KEY_TUNER
-+ KEY_TEXT
-+ KEY_NUMERIC_1
-+ KEY_NUMERIC_2
-+ KEY_NUMERIC_3
-+ KEY_NUMERIC_4
-+ KEY_NUMERIC_5
-+ KEY_NUMERIC_6
-+ KEY_NUMERIC_7
-+ KEY_NUMERIC_8
-+ KEY_NUMERIC_9
-+ KEY_NUMERIC_0
-+ KEY_NUMERIC_STAR
-+ KEY_NUMERIC_POUND
-+ KEY_RED
-+ KEY_GREEN
-+ KEY_YELLOW
-+ KEY_BLUE
-+
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.01-cdrip-PR616.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.01-cdrip-PR616.patch
deleted file mode 100644
index 830722aabf..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.01-cdrip-PR616.patch
+++ /dev/null
@@ -1,144 +0,0 @@
-From ab72a555c5dd8585ac6e101d9f5966e25500867d Mon Sep 17 00:00:00 2001
-From: Giftie
-Date: Thu, 5 Jan 2012 19:32:14 -0700
-Subject: [PATCH] Updated auto cd rip modified:
- language/English/strings.xml modified:
- xbmc/cdrip/CDDARipper.cpp modified:
- xbmc/settings/GUISettings.cpp modified:
- xbmc/settings/GUISettings.h modified:
- xbmc/storage/MediaManager.cpp modified: xbmc/Autorun.cpp
-
- Author: Giftie
- Committer: Giftie
----
- language/English/strings.xml | 5 ++++-
- xbmc/Autorun.cpp | 15 ++++++++++++---
- xbmc/settings/GUISettings.cpp | 8 +++++++-
- xbmc/settings/GUISettings.h | 5 +++++
- xbmc/storage/MediaManager.cpp | 7 +++++--
- 5 files changed, 33 insertions(+), 7 deletions(-)
-
-diff --git a/language/English/strings.xml b/language/English/strings.xml
-index ca2ac4d..ae22214 100644
---- a/language/English/strings.xml
-+++ b/language/English/strings.xml
-@@ -1344,7 +1344,7 @@
- Show EXIF picture information
- Use a fullscreen window rather than true fullscreen
- Queue songs on selection
-- Play audio CDs automatically
-+
- Playback
- DVDs
- Play DVDs automatically
-@@ -1355,6 +1355,9 @@
- Security
- Input devices
- Power saving
-+ Rip
-+ Audio CD Insert Action
-+ Play
-
- Remove
- Games
-diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp
-index 846b28d..3cd6f75 100644
---- a/xbmc/Autorun.cpp
-+++ b/xbmc/Autorun.cpp
-@@ -43,6 +43,9 @@
- #include "dialogs/GUIDialogYesNo.h"
- #include "utils/URIUtils.h"
- #include "utils/log.h"
-+#ifdef HAS_CDDA_RIPPER
-+#include "cdrip/CDDARipper.h"
-+#endif
-
- using namespace std;
- using namespace XFILE;
-@@ -69,13 +72,19 @@ void CAutorun::ExecuteAutorun(const CStdString& path, bool bypassSettings, bool
-
- g_application.ResetScreenSaver();
- g_application.WakeUpScreenSaverAndDPMS(); // turn off the screensaver if it's active
--
-+#ifdef HAS_CDDA_RIPPER
-+ if ( g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_RIP && pInfo->IsAudio(1) && !g_settings.GetCurrentProfile().musicLocked())
-+ {
-+ CCDDARipper ripper;
-+ ripper.RipCD();
-+ }
-+#endif
- PlayDisc(path, bypassSettings, startFromBeginning);
- }
-
- bool CAutorun::PlayDisc(const CStdString& path, bool bypassSettings, bool startFromBeginning)
- {
-- if ( !bypassSettings && !g_guiSettings.GetBool("audiocds.autorun") && !g_guiSettings.GetBool("dvds.autorun"))
-+ if ( !bypassSettings && !g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_PLAY && !g_guiSettings.GetBool("dvds.autorun"))
- return false;
-
- int nSize = g_playlistPlayer.GetPlaylist( PLAYLIST_MUSIC ).size();
-@@ -276,7 +285,7 @@ bool CAutorun::RunDisc(IDirectory* pDir, const CStdString& strDrive, int& nAdded
- }
- }
- // then music
-- if (!bPlaying && (bypassSettings || g_guiSettings.GetBool("audiocds.autorun")) && bAllowMusic)
-+ if (!bPlaying && (bypassSettings || g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_PLAY) && bAllowMusic)
- {
- for (int i = 0; i < vecItems.Size(); i++)
- {
-diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp
-index 6cce6ac..a0c7bf5 100644
---- a/xbmc/settings/GUISettings.cpp
-+++ b/xbmc/settings/GUISettings.cpp
-@@ -318,7 +318,13 @@ void CGUISettings::Initialize()
- AddString(scr, "scrobbler.librefmpass", 15219, "", EDIT_CONTROL_MD5_INPUT, false, 15219);
-
- CSettingsCategory* acd = AddCategory(3, "audiocds", 620);
-- AddBool(acd, "audiocds.autorun", 14085, false);
-+ map autocd;
-+ autocd.insert(make_pair(16018, AUTOCD_NONE));
-+ autocd.insert(make_pair(14098, AUTOCD_PLAY));
-+#ifdef HAS_CDDA_RIPPER
-+ autocd.insert(make_pair(14096, AUTOCD_RIP));
-+#endif
-+ AddInt(acd,"audiocds.autoaction",14097,AUTOCD_NONE, autocd, SPIN_CONTROL_TEXT);
- AddBool(acd, "audiocds.usecddb", 227, true);
- AddSeparator(acd, "audiocds.sep1");
- AddPath(acd,"audiocds.recordingpath",20000,"select writable folder",BUTTON_CONTROL_PATH_INPUT,false,657);
-diff --git a/xbmc/settings/GUISettings.h b/xbmc/settings/GUISettings.h
-index 5501064..8751624 100644
---- a/xbmc/settings/GUISettings.h
-+++ b/xbmc/settings/GUISettings.h
-@@ -64,6 +64,11 @@
- #define KARAOKE_COLOR_START 0
- #define KARAOKE_COLOR_END 4
-
-+// CDDA Autoaction defines
-+#define AUTOCD_NONE 0
-+#define AUTOCD_PLAY 1
-+#define AUTOCD_RIP 2
-+
- // CDDA ripper defines
- #define CDDARIP_ENCODER_LAME 0
- #define CDDARIP_ENCODER_VORBIS 1
-diff --git a/xbmc/storage/MediaManager.cpp b/xbmc/storage/MediaManager.cpp
-index ced4ad0..316e8c9 100644
---- a/xbmc/storage/MediaManager.cpp
-+++ b/xbmc/storage/MediaManager.cpp
-@@ -624,8 +624,11 @@ void CMediaManager::ProcessEvents()
-
- void CMediaManager::OnStorageAdded(const CStdString &label, const CStdString &path)
- {
-- if (g_guiSettings.GetBool("audiocds.autorun") || g_guiSettings.GetBool("dvds.autorun"))
-- CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_HIGH);
-+ if (g_guiSettings.GetInt("audiocds.autoaction") != AUTOCD_NONE || g_guiSettings.GetBool("dvds.autorun"))
-+ if ( g_guiSettings.GetInt("audiocds.autoaction") == AUTOCD_RIP)
-+ CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_LOW);
-+ else
-+ CJobManager::GetInstance().AddJob(new CAutorunMediaJob(label, path), this, CJob::PRIORITY_HIGH);
- else
- CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Info, g_localizeStrings.Get(13021), label, TOAST_DISPLAY_TIME, false);
- }
---
-1.7.5.4
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.02-cdrip-PR718.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.02-cdrip-PR718.patch
deleted file mode 100644
index f8fd6b6c73..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-806.02-cdrip-PR718.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-diff -Naur xbmc-pvr-fc63e66/language/English/strings.xml xbmc-pvr-fc63e66.patch/language/English/strings.xml
---- xbmc-pvr-fc63e66/language/English/strings.xml 2012-03-19 21:20:31.531809910 +0100
-+++ xbmc-pvr-fc63e66.patch/language/English/strings.xml 2012-03-19 21:21:56.576430020 +0100
-@@ -1360,6 +1360,7 @@
- Rip
- Audio CD Insert Action
- Play
-+ Eject disc when Audio CD ripping is complete
-
- Remove
- Games
-diff -Naur xbmc-pvr-fc63e66/xbmc/cdrip/CDDARipper.cpp xbmc-pvr-fc63e66.patch/xbmc/cdrip/CDDARipper.cpp
---- xbmc-pvr-fc63e66/xbmc/cdrip/CDDARipper.cpp 2012-03-16 22:27:56.000000000 +0100
-+++ xbmc-pvr-fc63e66.patch/xbmc/cdrip/CDDARipper.cpp 2012-03-19 21:21:07.725417655 +0100
-@@ -332,6 +332,11 @@
- }
-
- CLog::Log(LOGINFO, "Ripped CD succesfull");
-+ if (g_guiSettings.GetBool("audiocds.ejectonrip"))
-+ {
-+ CLog::Log(LOGINFO, "Ejecting CD");
-+ CIoSupport::EjectTray();
-+ }
- return true;
- }
-
-diff -Naur xbmc-pvr-fc63e66/xbmc/settings/GUISettings.cpp xbmc-pvr-fc63e66.patch/xbmc/settings/GUISettings.cpp
---- xbmc-pvr-fc63e66/xbmc/settings/GUISettings.cpp 2012-03-19 21:20:31.533809950 +0100
-+++ xbmc-pvr-fc63e66.patch/xbmc/settings/GUISettings.cpp 2012-03-19 21:21:07.734417841 +0100
-@@ -349,6 +349,7 @@
- AddInt(acd, "audiocds.quality", 622, CDDARIP_QUALITY_CBR, qualities, SPIN_CONTROL_TEXT);
- AddInt(acd, "audiocds.bitrate", 623, 192, 128, 32, 320, SPIN_CONTROL_INT_PLUS, MASK_KBPS);
- AddInt(acd, "audiocds.compressionlevel", 665, 5, 0, 1, 8, SPIN_CONTROL_INT_PLUS);
-+ AddBool(acd, "audiocds.ejectonrip", 14099, false);
-
- #ifdef HAS_KARAOKE
- CSettingsCategory* kar = AddCategory(3, "karaoke", 13327);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.01-ffmpeg-10.2-28b186f.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.01-ffmpeg-10.2-28b186f.patch
deleted file mode 100644
index 10c105e1a7..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.01-ffmpeg-10.2-28b186f.patch
+++ /dev/null
@@ -1,3239 +0,0 @@
-diff --git a/configure.in b/configure.in
-index c8bf4f1..fe7c790 100755
---- a/configure.in
-+++ b/configure.in
-@@ -2052,7 +2052,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
- --disable-amd3dnow \
- --disable-armv5te \
- --disable-armv6t2 \
-- --disable-static \
-+ --enable-static \
- `if test "$use_debug" = "no"; then echo --disable-debug; fi` \
- --disable-muxers \
- --enable-muxer=spdif \
-@@ -2066,7 +2066,6 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
- --disable-ffplay \
- --disable-ffserver \
- --disable-ffmpeg \
-- --enable-shared \
- --disable-doc \
- --disable-decoder=mpeg_xvmc \
- --enable-postproc \
-@@ -2074,6 +2073,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
- --enable-protocol=http \
- --enable-pthreads \
- --enable-runtime-cpudetect \
-+ --disable-openmp \
- --cc="$CC" &&
- sed -ie "s#YASM=yasm#YASM=${prefix}/bin/yasm#" config.mak &&
- sed -ie "s#YASMDEP=yasm#YASMDEP=${prefix}/bin/yasm#" config.mak &&
-diff --git a/lib/DllAvCodec.h b/lib/DllAvCodec.h
-index 463ab48..1ab00ea 100644
---- a/lib/DllAvCodec.h
-+++ b/lib/DllAvCodec.h
-@@ -24,7 +24,7 @@
- #include "config.h"
- #endif
- #include "DynamicDll.h"
--#include "DllAvCore.h"
-+#include "DllAvUtil.h"
- #include "utils/log.h"
-
- extern "C" {
-@@ -76,28 +76,6 @@ extern "C" {
- #endif
- }
-
--/* Some convenience macros introduced at this particular revision of libavcodec.
-- */
--#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52,25,0)
--#define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT)
--#define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY)
--#undef CH_LAYOUT_7POINT1_WIDE
--#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\
-- CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
--#endif
--
--#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52,64,0)
--// API added on: 2010-03-31
--#define AVMediaType CodecType
--#define AVMEDIA_TYPE_UNKNOWN CODEC_TYPE_UNKNOWN
--#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
--#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
--#define AVMEDIA_TYPE_DATA CODEC_TYPE_DATA
--#define AVMEDIA_TYPE_SUBTITLE CODEC_TYPE_SUBTITLE
--#define AVMEDIA_TYPE_ATTACHMENT CODEC_TYPE_ATTACHMENT
--#define AVMEDIA_TYPE_NB CODEC_TYPE_NB
--#endif
--
- #include "threads/SingleLock.h"
-
- class DllAvCodecInterface
-@@ -106,20 +84,20 @@ public:
- virtual ~DllAvCodecInterface() {}
- virtual void avcodec_register_all(void)=0;
- virtual void avcodec_flush_buffers(AVCodecContext *avctx)=0;
-- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec)=0;
-+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)=0;
- virtual AVCodec *avcodec_find_decoder(enum CodecID id)=0;
- virtual AVCodec *avcodec_find_encoder(enum CodecID id)=0;
- virtual int avcodec_close_dont_call(AVCodecContext *avctx)=0;
- virtual AVFrame *avcodec_alloc_frame(void)=0;
- virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height)=0;
- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)=0;
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt)=0;
-+ virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)=0;
- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)=0;
- virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples)=0;
- virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height)=0;
-- virtual AVCodecContext *avcodec_alloc_context(void)=0;
-+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec)=0;
- virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)=0;
-- virtual void avcodec_get_context_defaults(AVCodecContext *s)=0;
-+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec)=0;
- virtual AVCodecParserContext *av_parser_init(int codec_id)=0;
- virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size,
-@@ -137,7 +115,6 @@ public:
- virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt)=0;
- virtual int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic)=0;
- virtual void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic)=0;
-- virtual int avcodec_thread_init(AVCodecContext *s, int thread_count)=0;
- virtual AVCodec *av_codec_next(AVCodec *c)=0;
- virtual AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
- enum AVSampleFormat in_fmt , int in_channels,
-@@ -151,7 +128,7 @@ public:
- virtual int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // Use direct layer
- class DllAvCodec : public DllDynamic, DllAvCodecInterface
-@@ -166,12 +143,12 @@ public:
- ::avcodec_register_all();
- }
- virtual void avcodec_flush_buffers(AVCodecContext *avctx) { ::avcodec_flush_buffers(avctx); }
-- virtual int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-+ virtual int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return ::avcodec_open(avctx, codec);
-+ return ::avcodec_open2(avctx, codec, options);
- }
-- virtual int avcodec_open_dont_call(AVCodecContext *avctx, AVCodec *codec) { *(int *)0x0 = 0; return 0; }
-+ virtual int avcodec_open2_dont_call(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options) { *(int *)0x0 = 0; return 0; }
- virtual int avcodec_close_dont_call(AVCodecContext *avctx) { *(int *)0x0 = 0; return 0; }
- virtual AVCodec *avcodec_find_decoder(enum CodecID id) { return ::avcodec_find_decoder(id); }
- virtual AVCodec *avcodec_find_encoder(enum CodecID id) { return ::avcodec_find_encoder(id); }
-@@ -182,33 +159,21 @@ public:
- }
- virtual AVFrame *avcodec_alloc_frame() { return ::avcodec_alloc_frame(); }
- virtual int avpicture_fill(AVPicture *picture, uint8_t *ptr, PixelFormat pix_fmt, int width, int height) { return ::avpicture_fill(picture, ptr, pix_fmt, width, height); }
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,23,0)
-- // API added on: 2009-04-07
- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video2(avctx, picture, got_picture_ptr, avpkt); }
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio3(avctx, samples, frame_size_ptr, avpkt); }
-+ virtual int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio4(avctx, frame, got_frame_ptr, avpkt); }
- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle2(avctx, sub, got_sub_ptr, avpkt); }
--#else
-- virtual int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt) { return ::avcodec_decode_video(avctx, picture, got_picture_ptr, avpkt->data, avpkt->size); }
-- virtual int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt) { return ::avcodec_decode_audio2(avctx, samples, frame_size_ptr, avpkt->data, avpkt->size); }
-- virtual int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { return ::avcodec_decode_subtitle(avctx, sub, got_sub_ptr, avpkt->data, avpkt->size); }
--#endif
- virtual int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, const short *samples) { return ::avcodec_encode_audio(avctx, buf, buf_size, samples); }
- virtual int avpicture_get_size(PixelFormat pix_fmt, int width, int height) { return ::avpicture_get_size(pix_fmt, width, height); }
-- virtual AVCodecContext *avcodec_alloc_context() { return ::avcodec_alloc_context(); }
-+ virtual AVCodecContext *avcodec_alloc_context3(AVCodec *codec) { return ::avcodec_alloc_context3(codec); }
- virtual void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { ::avcodec_string(buf, buf_size, enc, encode); }
-- virtual void avcodec_get_context_defaults(AVCodecContext *s) { ::avcodec_get_context_defaults(s); }
-+ virtual void avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec) { ::avcodec_get_context_defaults3(s, codec); }
-
- virtual AVCodecParserContext *av_parser_init(int codec_id) { return ::av_parser_init(codec_id); }
- virtual int av_parser_parse2(AVCodecParserContext *s,AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size,
- const uint8_t *buf, int buf_size,
- int64_t pts, int64_t dts, int64_t pos)
- {
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,21,0)
-- // API added on : 2009-03-05
- return ::av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, pos);
--#else
-- return ::av_parser_parse(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts);
--#endif
- }
- virtual void av_parser_close(AVCodecParserContext *s) { ::av_parser_close(s); }
-
-@@ -225,7 +190,6 @@ public:
- virtual int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic) { return ::avcodec_default_get_buffer(s, pic); }
- virtual void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic) { ::avcodec_default_release_buffer(s, pic); }
- virtual enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat *fmt) { return ::avcodec_default_get_format(s, fmt); }
-- virtual int avcodec_thread_init(AVCodecContext *s, int thread_count) { return ::avcodec_thread_init(s, thread_count); }
- virtual AVCodec *av_codec_next(AVCodec *c) { return ::av_codec_next(c); }
- virtual AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
- enum AVSampleFormat in_fmt , int in_channels,
-@@ -256,12 +220,12 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
- {
- DECLARE_DLL_WRAPPER(DllAvCodec, DLL_PATH_LIBAVCODEC)
- DEFINE_FUNC_ALIGNED1(void, __cdecl, avcodec_flush_buffers, AVCodecContext*)
-- DEFINE_FUNC_ALIGNED2(int, __cdecl, avcodec_open_dont_call, AVCodecContext*, AVCodec *)
-+ DEFINE_FUNC_ALIGNED3(int, __cdecl, avcodec_open2_dont_call, AVCodecContext*, AVCodec *, AVDictionary **)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_video2, AVCodecContext*, AVFrame*, int*, AVPacket*)
-- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio3, AVCodecContext*, int16_t*, int*, AVPacket*)
-+ DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_audio4, AVCodecContext*, AVFrame*, int*, AVPacket*)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_decode_subtitle2, AVCodecContext*, AVSubtitle*, int*, AVPacket*)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, avcodec_encode_audio, AVCodecContext*, uint8_t*, int, const short*)
-- DEFINE_FUNC_ALIGNED0(AVCodecContext*, __cdecl, avcodec_alloc_context)
-+ DEFINE_FUNC_ALIGNED1(AVCodecContext*, __cdecl, avcodec_alloc_context3, AVCodec *)
- DEFINE_FUNC_ALIGNED1(AVCodecParserContext*, __cdecl, av_parser_init, int)
- DEFINE_FUNC_ALIGNED9(int, __cdecl, av_parser_parse2, AVCodecParserContext*,AVCodecContext*, uint8_t**, int*, const uint8_t*, int, int64_t, int64_t, int64_t)
- DEFINE_METHOD1(int, av_dup_packet, (AVPacket *p1))
-@@ -278,7 +242,7 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
- DEFINE_METHOD5(int, avpicture_fill, (AVPicture *p1, uint8_t *p2, PixelFormat p3, int p4, int p5))
- DEFINE_METHOD3(int, avpicture_get_size, (PixelFormat p1, int p2, int p3))
- DEFINE_METHOD4(void, avcodec_string, (char *p1, int p2, AVCodecContext *p3, int p4))
-- DEFINE_METHOD1(void, avcodec_get_context_defaults, (AVCodecContext *p1))
-+ DEFINE_METHOD2(void, avcodec_get_context_defaults3, (AVCodecContext *p1, AVCodec *p2))
- DEFINE_METHOD1(void, av_parser_close, (AVCodecParserContext *p1))
- DEFINE_METHOD1(void, avpicture_free, (AVPicture *p1))
- DEFINE_METHOD1(AVBitStreamFilterContext*, av_bitstream_filter_init, (const char *p1))
-@@ -290,7 +254,6 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
- DEFINE_METHOD2(void, avcodec_default_release_buffer, (AVCodecContext *p1, AVFrame *p2))
- DEFINE_METHOD2(enum PixelFormat, avcodec_default_get_format, (struct AVCodecContext *p1, const enum PixelFormat *p2))
-
-- DEFINE_METHOD2(int, avcodec_thread_init, (AVCodecContext *p1, int p2))
- DEFINE_METHOD1(AVCodec*, av_codec_next, (AVCodec *p1))
- DEFINE_METHOD6(AVAudioConvert*, av_audio_convert_alloc, (enum AVSampleFormat p1, int p2,
- enum AVSampleFormat p3, int p4,
-@@ -301,7 +264,7 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
- const void * const p4[6], const int p5[6], int p6))
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(avcodec_flush_buffers)
-- RESOLVE_METHOD_RENAME(avcodec_open,avcodec_open_dont_call)
-+ RESOLVE_METHOD_RENAME(avcodec_open2,avcodec_open2_dont_call)
- RESOLVE_METHOD_RENAME(avcodec_close,avcodec_close_dont_call)
- RESOLVE_METHOD(avcodec_find_decoder)
- RESOLVE_METHOD(avcodec_find_encoder)
-@@ -309,13 +272,13 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
- RESOLVE_METHOD_RENAME(avcodec_register_all, avcodec_register_all_dont_call)
- RESOLVE_METHOD(avpicture_fill)
- RESOLVE_METHOD(avcodec_decode_video2)
-- RESOLVE_METHOD(avcodec_decode_audio3)
-+ RESOLVE_METHOD(avcodec_decode_audio4)
- RESOLVE_METHOD(avcodec_decode_subtitle2)
- RESOLVE_METHOD(avcodec_encode_audio)
- RESOLVE_METHOD(avpicture_get_size)
-- RESOLVE_METHOD(avcodec_alloc_context)
-+ RESOLVE_METHOD(avcodec_alloc_context3)
- RESOLVE_METHOD(avcodec_string)
-- RESOLVE_METHOD(avcodec_get_context_defaults)
-+ RESOLVE_METHOD(avcodec_get_context_defaults3)
- RESOLVE_METHOD(av_parser_init)
- RESOLVE_METHOD(av_parser_parse2)
- RESOLVE_METHOD(av_parser_close)
-@@ -328,7 +291,6 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
- RESOLVE_METHOD(avcodec_default_get_buffer)
- RESOLVE_METHOD(avcodec_default_release_buffer)
- RESOLVE_METHOD(avcodec_default_get_format)
-- RESOLVE_METHOD(avcodec_thread_init)
- RESOLVE_METHOD(av_codec_next)
- RESOLVE_METHOD(av_audio_convert_alloc)
- RESOLVE_METHOD(av_audio_convert_free)
-@@ -339,15 +301,15 @@ class DllAvCodec : public DllDynamic, DllAvCodecInterface
- END_METHOD_RESOLVE()
-
- /* dependencies of libavcodec */
-- DllAvCore m_dllAvCore;
-+ DllAvUtil m_dllAvUtil;
- // DllAvUtil loaded implicitely by m_dllAvCore
-
- public:
- static CCriticalSection m_critSection;
-- int avcodec_open(AVCodecContext *avctx, AVCodec *codec)
-+ int avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return avcodec_open_dont_call(avctx,codec);
-+ return avcodec_open2_dont_call(avctx,codec, options);
- }
- int avcodec_close(AVCodecContext *avctx)
- {
-@@ -361,7 +323,7 @@ public:
- }
- virtual bool Load()
- {
-- if (!m_dllAvCore.Load())
-+ if (!m_dllAvUtil.Load())
- return false;
- return DllDynamic::Load();
- }
-diff --git a/lib/DllAvCore.h b/lib/DllAvCore.h
-deleted file mode 100644
-index 92a7ab7..0000000
---- a/lib/DllAvCore.h
-+++ /dev/null
-@@ -1,182 +0,0 @@
--#pragma once
--/*
-- * Copyright (C) 2005-2010 Team XBMC
-- * http://www.xbmc.org
-- *
-- * This Program 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, or (at your option)
-- * any later version.
-- *
-- * This Program 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 XBMC; see the file COPYING. If not, write to the Free
-- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-- * Boston, MA 02110-1301, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#if (defined HAVE_CONFIG_H) && (!defined WIN32)
-- #include "config.h"
--#endif
--#include "DynamicDll.h"
--#include "DllAvUtil.h"
--#include "utils/log.h"
--
--extern "C" {
--#ifdef USE_EXTERNAL_FFMPEG
-- #ifdef HAVE_LIBAVUTIL_SAMPLEFMT_H
-- // libavcore was merged to libavutil on 2010-02-15
-- #include
-- #include
-- #endif
--
-- #ifdef HAVE_LIBAVCORE_AVCORE_H
-- #include
-- #endif
-- #ifdef HAVE_LIBAVCORE_SAMPLEFMT_H
-- #include
-- #endif
--
-- /* Needed for old FFmpeg versions as used below */
-- #ifdef HAVE_LIBAVCODEC_AVCODEC_H
-- #include
-- #else
-- #include
-- #endif
--#else
-- #include "libavcore/avcore.h"
-- #include "libavcore/samplefmt.h"
--#endif
--}
--
--/* Compatibility for old external FFmpeg versions. */
--
--#ifdef USE_EXTERNAL_FFMPEG
--
--#ifndef LIBAVCORE_VERSION_INT
--// API added on: 2010-07-21, removed on 2010-02-15
--#define LIBAVCORE_VERSION_INT 0
--#endif
--
--#ifndef AV_SAMPLE_FMT_NONE
--// API added on: 2010-11-02
--#define AVSampleFormat SampleFormat
--#define AV_SAMPLE_FMT_NONE SAMPLE_FMT_NONE
--#define AV_SAMPLE_FMT_U8 SAMPLE_FMT_U8
--#define AV_SAMPLE_FMT_S16 SAMPLE_FMT_S16
--#define AV_SAMPLE_FMT_S32 SAMPLE_FMT_S32
--#define AV_SAMPLE_FMT_FLT SAMPLE_FMT_FLT
--#define AV_SAMPLE_FMT_DBL SAMPLE_FMT_DBL
--#endif
--
--#ifndef AV_CH_FRONT_LEFT
--// API added on: 2010-11-21
--#define AV_CH_FRONT_LEFT CH_FRONT_LEFT
--#define AV_CH_FRONT_RIGHT CH_FRONT_RIGHT
--#define AV_CH_FRONT_CENTER CH_FRONT_CENTER
--#define AV_CH_LOW_FREQUENCY CH_LOW_FREQUENCY
--#define AV_CH_BACK_LEFT CH_BACK_LEFT
--#define AV_CH_BACK_RIGHT CH_BACK_RIGHT
--#define AV_CH_FRONT_LEFT_OF_CENTER CH_FRONT_LEFT_OF_CENTER
--#define AV_CH_FRONT_RIGHT_OF_CENTER CH_FRONT_RIGHT_OF_CENTER
--#define AV_CH_BACK_CENTER CH_BACK_CENTER
--#define AV_CH_SIDE_LEFT CH_SIDE_LEFT
--#define AV_CH_SIDE_RIGHT CH_SIDE_RIGHT
--#define AV_CH_TOP_CENTER CH_TOP_CENTER
--#define AV_CH_TOP_FRONT_LEFT CH_TOP_FRONT_LEFT
--#define AV_CH_TOP_FRONT_CENTER CH_TOP_FRONT_CENTER
--#define AV_CH_TOP_FRONT_RIGHT CH_TOP_FRONT_RIGHT
--#define AV_CH_TOP_BACK_LEFT CH_TOP_BACK_LEFT
--#define AV_CH_TOP_BACK_CENTER CH_TOP_BACK_CENTER
--#define AV_CH_TOP_BACK_RIGHT CH_TOP_BACK_RIGHT
--#define AV_CH_STEREO_LEFT CH_STEREO_LEFT
--#define AV_CH_STEREO_RIGHT CH_STEREO_RIGHT
--
--#define AV_CH_LAYOUT_NATIVE CH_LAYOUT_NATIVE
--
--#define AV_CH_LAYOUT_MONO CH_LAYOUT_MONO
--#define AV_CH_LAYOUT_STEREO CH_LAYOUT_STEREO
--#define AV_CH_LAYOUT_2_1 CH_LAYOUT_2_1
--#define AV_CH_LAYOUT_SURROUND CH_LAYOUT_SURROUND
--#define AV_CH_LAYOUT_4POINT0 CH_LAYOUT_4POINT0
--#define AV_CH_LAYOUT_2_2 CH_LAYOUT_2_2
--#define AV_CH_LAYOUT_QUAD CH_LAYOUT_QUAD
--#define AV_CH_LAYOUT_5POINT0 CH_LAYOUT_5POINT0
--#define AV_CH_LAYOUT_5POINT1 CH_LAYOUT_5POINT1
--#define AV_CH_LAYOUT_5POINT0_BACK CH_LAYOUT_5POINT0_BACK
--#define AV_CH_LAYOUT_5POINT1_BACK CH_LAYOUT_5POINT1_BACK
--#define AV_CH_LAYOUT_7POINT0 CH_LAYOUT_7POINT0
--#define AV_CH_LAYOUT_7POINT1 CH_LAYOUT_7POINT1
--#define AV_CH_LAYOUT_7POINT1_WIDE CH_LAYOUT_7POINT1_WIDE
--#define AV_CH_LAYOUT_STEREO_DOWNMIX CH_LAYOUT_STEREO_DOWNMIX
--#endif
--
--#endif // USE_EXTERNAL_FFMPEG
--
--class DllAvCoreInterface
--{
--public:
-- virtual ~DllAvCoreInterface() {}
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) = 0;
--};
--
--#if (defined USE_EXTERNAL_FFMPEG)
--
--// Use direct layer
--class DllAvCore : public DllDynamic, DllAvCoreInterface
--{
--public:
-- virtual ~DllAvCore() {}
--#if LIBAVCORE_VERSION_INT >= AV_VERSION_INT(0,12,0) || LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(50,38,0)
-- // API added on: 2010-11-02, moved to libavutil on 2010-02-15
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) { return ::av_get_bits_per_sample_fmt(sample_fmt); }
--#else
-- // from avcodec.h
-- virtual int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) { return ::av_get_bits_per_sample_format(sample_fmt); }
--#endif
--
-- // DLL faking.
-- virtual bool ResolveExports() { return true; }
-- virtual bool Load() {
--#if LIBAVCORE_VERSION_INT > 0
-- CLog::Log(LOGDEBUG, "DllAvCore: Using libavcore system library");
--#endif
-- return true;
-- }
-- virtual void Unload() {}
--};
--
--#else
--
--class DllAvCore : public DllDynamic, DllAvCoreInterface
--{
-- DECLARE_DLL_WRAPPER(DllAvCore, DLL_PATH_LIBAVCORE)
--
-- LOAD_SYMBOLS()
--
-- DEFINE_METHOD1(int, av_get_bits_per_sample_fmt, (enum AVSampleFormat p1))
--
-- BEGIN_METHOD_RESOLVE()
-- RESOLVE_METHOD(av_get_bits_per_sample_fmt)
-- END_METHOD_RESOLVE()
--
-- /* dependency of libavcore */
-- DllAvUtil m_dllAvUtil;
--
--public:
-- virtual bool Load()
-- {
-- if (!m_dllAvUtil.Load())
-- return false;
-- return DllDynamic::Load();
-- }
--};
--
--#endif
--
-diff --git a/lib/DllAvFilter.h b/lib/DllAvFilter.h
-index a421225..e363082 100644
---- a/lib/DllAvFilter.h
-+++ b/lib/DllAvFilter.h
-@@ -24,8 +24,8 @@
- #include "config.h"
- #endif
- #include "DynamicDll.h"
--#include "DllAvCore.h"
- #include "DllAvCodec.h"
-+#include "DllSwResample.h"
- #include "utils/log.h"
-
- extern "C" {
-@@ -43,28 +43,17 @@ extern "C" {
- #if (defined USE_EXTERNAL_FFMPEG)
- #if (defined HAVE_LIBAVFILTER_AVFILTER_H)
- #include
-+ #include
-+ #include
- #elif (defined HAVE_FFMPEG_AVFILTER_H)
- #include
-- #endif
-- /* for av_vsrc_buffer_add_frame */
-- #if (defined USE_OLD_AV_VSRC_BUFFER_ADD_FRAME)
-- #include
-- #else
-- #if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,8,0)
-- #include
-- #elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame);
-- #elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame, int64_t pts);
-- #else
-- int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
-- AVFrame *frame, int64_t pts, AVRational pixel_aspect);
-- #endif
-+ #include
-+ #include
- #endif
- #else
- #include "libavfilter/avfiltergraph.h"
-+ #include "libavfilter/buffersink.h"
-+ #include "libavfilter/avcodec.h"
- #endif
- }
-
-@@ -86,25 +75,16 @@ public:
- virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)=0;
- virtual int avfilter_poll_frame(AVFilterLink *link)=0;
- virtual int avfilter_request_frame(AVFilterLink *link)=0;
--#if (defined USE_OLD_AV_VSRC_BUFFER_ADD_FRAME)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect)=0;
--#else
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags)=0;
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame)=0;
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts)=0;
--#else
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect)=0;
--#endif
--#endif
- virtual AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)=0;
- virtual void avfilter_unref_buffer(AVFilterBufferRef *ref)=0;
- virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)=0;
-+ virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags)=0;
-+ virtual AVBufferSinkParams *av_buffersink_params_alloc()=0;
-+ virtual int av_buffersink_poll_frame(AVFilterContext *ctx)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
- // Use direct mapping
- class DllAvFilter : public DllDynamic, DllAvFilterInterface
- {
-@@ -123,12 +103,7 @@ public:
- virtual void avfilter_graph_free(AVFilterGraph **graph)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- ::avfilter_graph_free(graph);
--#else
-- ::avfilter_graph_free(*graph);
-- *graph = NULL;
--#endif
- }
- void avfilter_register_all()
- {
-@@ -141,60 +116,32 @@ public:
- virtual AVFilterInOut *avfilter_inout_alloc()
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- return ::avfilter_inout_alloc();
--#else
-- return (AVFilterInOut*)::av_mallocz(sizeof(AVFilterInOut));
--#endif
- }
- virtual void avfilter_inout_free(AVFilterInOut **inout)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- ::avfilter_inout_free(inout);
--#else
-- *inout = NULL;
--#endif
- }
- virtual int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if ( LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,79,0) \
-- && LIBAVFILTER_VERSION_INT < AV_VERSION_INT(2,0,0) ) \
-- ||( LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0))
- return ::avfilter_graph_parse(graph, filters, inputs, outputs, log_ctx);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- return ::avfilter_graph_parse(graph, filters, *inputs, *outputs, log_ctx);
--#else
-- return ::avfilter_graph_parse(graph, filters, *inputs, *outputs, (AVClass*)log_ctx);
--#endif
- }
- virtual int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
- {
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-+
- return ::avfilter_graph_config(graphctx, log_ctx);
--#else
-- return ::avfilter_graph_config(graphctx, (AVClass*)log_ctx);
--#endif
- }
- virtual int avfilter_poll_frame(AVFilterLink *link) { return ::avfilter_poll_frame(link); }
- virtual int avfilter_request_frame(AVFilterLink *link) { return ::avfilter_request_frame(link); }
--#if (defined USE_OLD_AV_VSRC_BUFFER_ADD_FRAME)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, pts, pixel_aspect); }
--#else
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int flags) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, flags); }
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame); }
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, pts); }
--#else
-- virtual int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, int64_t pts, AVRational pixel_aspect) { return ::av_vsrc_buffer_add_frame(buffer_filter, frame, pts, pixel_aspect); }
--#endif
--#endif
- virtual AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { return ::avfilter_get_video_buffer(link, perms, w, h); }
- virtual void avfilter_unref_buffer(AVFilterBufferRef *ref) { ::avfilter_unref_buffer(ref); }
- virtual int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad) { return ::avfilter_link(src, srcpad, dst, dstpad); }
-+ virtual int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink, AVFilterBufferRef **bufref, int flags) { return ::av_buffersink_get_buffer_ref(buffer_sink, bufref, flags); }
-+ virtual AVBufferSinkParams *av_buffersink_params_alloc() { return ::av_buffersink_params_alloc(); }
-+ virtual int av_buffersink_poll_frame(AVFilterContext *ctx) { return av_buffersink_poll_frame(ctx); }
- // DLL faking.
- virtual bool ResolveExports() { return true; }
- virtual bool Load() {
-@@ -212,45 +159,24 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
-
- DEFINE_METHOD3(int, avfilter_open_dont_call, (AVFilterContext **p1, AVFilter *p2, const char *p3))
- DEFINE_METHOD1(void, avfilter_free_dont_call, (AVFilterContext *p1))
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- DEFINE_METHOD1(void, avfilter_graph_free_dont_call, (AVFilterGraph **p1))
--#else
-- DEFINE_METHOD1(void, avfilter_graph_free_dont_call, (AVFilterGraph *p1))
--#endif
- DEFINE_METHOD0(void, avfilter_register_all_dont_call)
- DEFINE_METHOD6(int, avfilter_graph_create_filter, (AVFilterContext **p1, AVFilter *p2, const char *p3, const char *p4, void *p5, AVFilterGraph *p6))
- DEFINE_METHOD1(AVFilter*, avfilter_get_by_name, (const char *p1))
- DEFINE_METHOD0(AVFilterGraph*, avfilter_graph_alloc)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- DEFINE_METHOD0(AVFilterInOut*, avfilter_inout_alloc_dont_call)
- DEFINE_METHOD1(void, avfilter_inout_free_dont_call, (AVFilterInOut **p1))
--#endif
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0)
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut **p3, AVFilterInOut **p4, void *p5))
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut *p3, AVFilterInOut *p4, void *p5))
--#else
-- DEFINE_METHOD5(int, avfilter_graph_parse_dont_call, (AVFilterGraph *p1, const char *p2, AVFilterInOut *p3, AVFilterInOut *p4, AVClass *p5))
--#endif
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- DEFINE_METHOD2(int, avfilter_graph_config_dont_call, (AVFilterGraph *p1, void *p2))
--#else
-- DEFINE_METHOD2(int, avfilter_graph_config_dont_call, (AVFilterGraph *p1, AVClass *p2))
--#endif
-+ DEFINE_FUNC_ALIGNED5(int, __cdecl, avfilter_graph_parse_dont_call, AVFilterGraph *, const char *, AVFilterInOut **, AVFilterInOut **, void *)
-+ DEFINE_FUNC_ALIGNED2(int, __cdecl, avfilter_graph_config_dont_call, AVFilterGraph *, void *)
- DEFINE_FUNC_ALIGNED1(int, __cdecl, avfilter_poll_frame, AVFilterLink *)
- DEFINE_FUNC_ALIGNED1(int, __cdecl, avfilter_request_frame, AVFilterLink*)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int p3))
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- DEFINE_METHOD2(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2))
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- DEFINE_METHOD3(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int64_t p3))
--#else
-- DEFINE_METHOD4(int, av_vsrc_buffer_add_frame, (AVFilterContext *p1, AVFrame *p2, int64_t p3, AVRational p4))
--#endif
- DEFINE_METHOD4(AVFilterBufferRef*, avfilter_get_video_buffer, (AVFilterLink *p1, int p2, int p3, int p4))
- DEFINE_METHOD1(void, avfilter_unref_buffer, (AVFilterBufferRef *p1))
- DEFINE_METHOD4(int, avfilter_link, (AVFilterContext *p1, unsigned p2, AVFilterContext *p3, unsigned p4))
-+ DEFINE_FUNC_ALIGNED3(int , __cdecl, av_buffersink_get_buffer_ref, AVFilterContext *, AVFilterBufferRef **, int);
-+ DEFINE_FUNC_ALIGNED0(AVBufferSinkParams*, __cdecl, av_buffersink_params_alloc);
-+ DEFINE_FUNC_ALIGNED1(int , __cdecl, av_buffersink_poll_frame, AVFilterContext *);
-
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD_RENAME(avfilter_open, avfilter_open_dont_call)
-@@ -260,10 +186,8 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
- RESOLVE_METHOD(avfilter_graph_create_filter)
- RESOLVE_METHOD(avfilter_get_by_name)
- RESOLVE_METHOD(avfilter_graph_alloc)
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- RESOLVE_METHOD_RENAME(avfilter_inout_alloc, avfilter_inout_alloc_dont_call)
- RESOLVE_METHOD_RENAME(avfilter_inout_free, avfilter_inout_free_dont_call)
--#endif
- RESOLVE_METHOD_RENAME(avfilter_graph_parse, avfilter_graph_parse_dont_call)
- RESOLVE_METHOD_RENAME(avfilter_graph_config, avfilter_graph_config_dont_call)
- RESOLVE_METHOD(avfilter_poll_frame)
-@@ -272,10 +196,14 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
- RESOLVE_METHOD(avfilter_get_video_buffer)
- RESOLVE_METHOD(avfilter_unref_buffer)
- RESOLVE_METHOD(avfilter_link)
-+ RESOLVE_METHOD(av_buffersink_get_buffer_ref)
-+ RESOLVE_METHOD(av_buffersink_params_alloc)
-+ RESOLVE_METHOD(av_buffersink_poll_frame)
- END_METHOD_RESOLVE()
-
- /* dependencies of libavfilter */
- DllAvUtil m_dllAvUtil;
-+ DllSwResample m_dllSwResample;
-
- public:
- int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
-@@ -291,12 +219,7 @@ public:
- void avfilter_graph_free(AVFilterGraph **graph)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(1,76,0)
- avfilter_graph_free_dont_call(graph);
--#else
-- avfilter_graph_free_dont_call(*graph);
-- m_dllAvUtil.av_freep(graph);
--#endif
- }
- void avfilter_register_all()
- {
-@@ -306,45 +229,29 @@ public:
- AVFilterInOut* avfilter_inout_alloc()
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- return avfilter_inout_alloc_dont_call();
--#else
-- return (AVFilterInOut*)m_dllAvUtil.av_mallocz(sizeof(AVFilterInOut));
--#endif
- }
- int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,16,0)
- return avfilter_graph_parse_dont_call(graph, filters, inputs, outputs, log_ctx);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
-- return avfilter_graph_parse_dont_call(graph, filters, *inputs, *outputs, log_ctx);
--#else
-- return avfilter_graph_parse_dont_call(graph, filters, *inputs, *outputs, (AVClass*)log_ctx);
--#endif
- }
- void avfilter_inout_free(AVFilterInOut **inout)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,17,0)
- avfilter_inout_free_dont_call(inout);
--#else
-- *inout = NULL;
--#endif
- }
- int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,15,1)
- return avfilter_graph_config_dont_call(graphctx, log_ctx);
--#else
-- return avfilter_graph_config_dont_call(graphctx, (AVClass*)log_ctx);
--#endif
- }
- virtual bool Load()
- {
- if (!m_dllAvUtil.Load())
- return false;
-+ if (!m_dllSwResample.Load())
-+ return false;
- return DllDynamic::Load();
- }
- };
-diff --git a/lib/DllAvFormat.h b/lib/DllAvFormat.h
-index 46a7481..72b8866 100644
---- a/lib/DllAvFormat.h
-+++ b/lib/DllAvFormat.h
-@@ -62,57 +62,45 @@ public:
- virtual ~DllAvFormatInterface() {}
- virtual void av_register_all_dont_call(void)=0;
- virtual AVInputFormat *av_find_input_format(const char *short_name)=0;
-- virtual int url_feof(ByteIOContext *s)=0;
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags)=0;
-- virtual void av_close_input_file(AVFormatContext *s)=0;
-- virtual void av_close_input_stream(AVFormatContext *s)=0;
-+ virtual int url_feof(AVIOContext *s)=0;
-+ virtual void avformat_close_input(AVFormatContext **s)=0;
- virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt)=0;
- virtual void av_read_frame_flush(AVFormatContext *s)=0;
- virtual int av_read_play(AVFormatContext *s)=0;
- virtual int av_read_pause(AVFormatContext *s)=0;
- virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)=0;
--#if (!defined USE_EXTERNAL_FFMPEG)
-- virtual int av_find_stream_info_dont_call(AVFormatContext *ic)=0;
-+#if (!defined USE_EXTERNAL_FFMPEG) && (!defined TARGET_DARWIN)
-+ virtual int avformat_find_stream_info_dont_call(AVFormatContext *ic, AVDictionary **options)=0;
- #endif
-- virtual int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap)=0;
-- virtual void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)=0;
-- virtual int av_open_input_stream(AVFormatContext **ic_ptr, ByteIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap)=0;
-- virtual int init_put_byte(ByteIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-+ virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)=0;
-+ virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
- offset_t (*seek)(void *opaque, offset_t offset, int whence))=0;
- virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)=0;
- virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max)=0;
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)=0;
-- virtual void dump_format(AVFormatContext *ic, int index, const char *url, int is_output)=0;
-- virtual int url_fdopen(ByteIOContext **s, URLContext *h)=0;
-- virtual int url_fopen(ByteIOContext **s, const char *filename, int flags)=0;
-- virtual int url_fclose(ByteIOContext *s)=0;
-- virtual int url_open_dyn_buf(ByteIOContext **s)=0;
-- virtual int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)=0;
-- virtual offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence)=0;
-- virtual int get_buffer(ByteIOContext *s, unsigned char *buf, int size)=0;
-- virtual int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size)=0;
-- virtual void put_byte(ByteIOContext *s, int b)=0;
-- virtual void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)=0;
-- virtual void put_be24(ByteIOContext *s, unsigned int val)=0;
-- virtual void put_be32(ByteIOContext *s, unsigned int val)=0;
-- virtual void put_be16(ByteIOContext *s, unsigned int val)=0;
-+ virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)=0;
-+ virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)=0;
-+ virtual int avio_open(AVIOContext **s, const char *filename, int flags)=0;
-+ virtual int avio_close(AVIOContext *s)=0;
-+ virtual int avio_open_dyn_buf(AVIOContext **s)=0;
-+ virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)=0;
-+ virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence)=0;
-+ virtual int avio_read(AVIOContext *s, unsigned char *buf, int size)=0;
-+ virtual void avio_w8(AVIOContext *s, int b)=0;
-+ virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size)=0;
-+ virtual void avio_wb24(AVIOContext *s, unsigned int val)=0;
-+ virtual void avio_wb32(AVIOContext *s, unsigned int val)=0;
-+ virtual void avio_wb16(AVIOContext *s, unsigned int val)=0;
- virtual AVFormatContext *avformat_alloc_context(void)=0;
-- virtual AVStream *av_new_stream(AVFormatContext *s, int id)=0;
-+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)=0;
- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type)=0;
-- virtual int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)=0;
-- virtual ByteIOContext *av_alloc_put_byte(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence))=0;
-- virtual int av_write_header (AVFormatContext *s)=0;
-+ virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options)=0;
- virtual int av_write_trailer(AVFormatContext *s)=0;
- virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt)=0;
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // Use direct mapping
- class DllAvFormat : public DllDynamic, DllAvFormatInterface
-@@ -126,78 +114,45 @@ public:
- }
- virtual void av_register_all_dont_call() { *(int* )0x0 = 0; }
- virtual AVInputFormat *av_find_input_format(const char *short_name) { return ::av_find_input_format(short_name); }
-- virtual int url_feof(ByteIOContext *s) { return ::url_feof(s); }
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,31,0)
-- // API added on: 2009-03-01
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags){ return ::av_metadata_get(m, key, prev, flags); }
--#else
-- virtual AVMetadataTag *av_metadata_get(AVMetadata *m, const char *key, const AVMetadataTag *prev, int flags){ return NULL; }
--#endif
-- virtual void av_close_input_file(AVFormatContext *s) { ::av_close_input_file(s); }
-- virtual void av_close_input_stream(AVFormatContext *s) { ::av_close_input_stream(s); }
-+ virtual int url_feof(AVIOContext *s) { return ::url_feof(s); }
-+ virtual void avformat_close_input(AVFormatContext **s) { ::avformat_close_input(s); }
- virtual int av_read_frame(AVFormatContext *s, AVPacket *pkt) { return ::av_read_frame(s, pkt); }
- virtual void av_read_frame_flush(AVFormatContext *s) { ::av_read_frame_flush(s); }
- virtual int av_read_play(AVFormatContext *s) { return ::av_read_play(s); }
- virtual int av_read_pause(AVFormatContext *s) { return ::av_read_pause(s); }
- virtual int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { return ::av_seek_frame(s, stream_index, timestamp, flags); }
-- virtual int av_find_stream_info(AVFormatContext *ic)
-+ virtual int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return ::av_find_stream_info(ic);
-+ return ::avformat_find_stream_info(ic, options);
- }
-- virtual int av_open_input_file(AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap) { return ::av_open_input_file(ic_ptr, filename, fmt, buf_size, ap); }
-- virtual void url_set_interrupt_cb(URLInterruptCB *interrupt_cb) { ::url_set_interrupt_cb(interrupt_cb); }
-- virtual int av_open_input_stream(AVFormatContext **ic_ptr, ByteIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap) { return ::av_open_input_stream(ic_ptr, pb, filename, fmt, ap); }
-- virtual int init_put_byte(ByteIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-+ virtual int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
-+ { return ::avformat_open_input(ps, filename, fmt, options); }
-+ virtual AVIOContext *avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::init_put_byte(s, buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
-+ offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::avio_alloc_context(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
- virtual AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened) {return ::av_probe_input_format(pd, is_opened); }
- virtual AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max) {*score_max = 100; return ::av_probe_input_format(pd, is_opened); } // Use av_probe_input_format, this is not exported by ffmpeg's headers
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,98,0)
-- // API added on: 2010-02-08
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return ::av_probe_input_buffer(pb, fmt, filename, logctx, offset, max_probe_size); }
--#else
-- virtual int av_probe_input_buffer(ByteIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return -1; }
--#endif
-- virtual void dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { ::dump_format(ic, index, url, is_output); }
-- virtual int url_fdopen(ByteIOContext **s, URLContext *h) { return ::url_fdopen(s, h); }
-- virtual int url_fopen(ByteIOContext **s, const char *filename, int flags) { return ::url_fopen(s, filename, flags); }
-- virtual int url_fclose(ByteIOContext *s) { return ::url_fclose(s); }
-- virtual int url_open_dyn_buf(ByteIOContext **s) { return ::url_open_dyn_buf(s); }
-- virtual int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) { return ::url_close_dyn_buf(s, pbuffer); }
-- virtual offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence) { return ::url_fseek(s, offset, whence); }
-- virtual int get_buffer(ByteIOContext *s, unsigned char *buf, int size) { return ::get_buffer(s, buf, size); }
-- virtual int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size) { return ::get_partial_buffer(s, buf, size); }
-- virtual void put_byte(ByteIOContext *s, int b) { ::put_byte(s, b); }
-- virtual void put_buffer(ByteIOContext *s, const unsigned char *buf, int size) { ::put_buffer(s, buf, size); }
-- virtual void put_be24(ByteIOContext *s, unsigned int val) { ::put_be24(s, val); }
-- virtual void put_be32(ByteIOContext *s, unsigned int val) { ::put_be32(s, val); }
-- virtual void put_be16(ByteIOContext *s, unsigned int val) { ::put_be16(s, val); }
-+ virtual int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size) { return ::av_probe_input_buffer(pb, fmt, filename, logctx, offset, max_probe_size); }
-+ virtual void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output) { ::av_dump_format(ic, index, url, is_output); }
-+ virtual int avio_open(AVIOContext **s, const char *filename, int flags) { return ::avio_open(s, filename, flags); }
-+ virtual int avio_close(AVIOContext *s) { return ::avio_close(s); }
-+ virtual int avio_open_dyn_buf(AVIOContext **s) { return ::avio_open_dyn_buf(s); }
-+ virtual int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return ::avio_close_dyn_buf(s, pbuffer); }
-+ virtual offset_t avio_seek(AVIOContext *s, offset_t offset, int whence) { return ::avio_seek(s, offset, whence); }
-+ virtual int avio_read(AVIOContext *s, unsigned char *buf, int size) { return ::avio_read(s, buf, size); }
-+ virtual void avio_w8(AVIOContext *s, int b) { ::avio_w8(s, b); }
-+ virtual void avio_write(AVIOContext *s, const unsigned char *buf, int size) { ::avio_write(s, buf, size); }
-+ virtual void avio_wb24(AVIOContext *s, unsigned int val) { ::avio_wb24(s, val); }
-+ virtual void avio_wb32(AVIOContext *s, unsigned int val) { ::avio_wb32(s, val); }
-+ virtual void avio_wb16(AVIOContext *s, unsigned int val) { ::avio_wb16(s, val); }
- virtual AVFormatContext *avformat_alloc_context() { return ::avformat_alloc_context(); }
-- virtual AVStream *av_new_stream(AVFormatContext *s, int id) { return ::av_new_stream(s, id); }
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::guess_format(short_name, filename, mime_type); }
--#else
-+ virtual AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) { return ::avformat_new_stream(s, c); }
- virtual AVOutputFormat *av_guess_format(const char *short_name, const char *filename, const char *mime_type) { return ::av_guess_format(short_name, filename, mime_type); }
--#endif
-- virtual int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) { return ::av_set_parameters(s, ap); }
-- virtual ByteIOContext *av_alloc_put_byte(unsigned char *buffer, int buffer_size, int write_flag, void *opaque,
-- int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
-- int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*seek)(void *opaque, offset_t offset, int whence)) { return ::av_alloc_put_byte(buffer, buffer_size, write_flag, opaque, read_packet, write_packet, seek); }
-- virtual int av_write_header (AVFormatContext *s) { return ::av_write_header (s); }
-+ virtual int avformat_write_header (AVFormatContext *s, AVDictionary **options) { return ::avformat_write_header (s, options); }
- virtual int av_write_trailer(AVFormatContext *s) { return ::av_write_trailer(s); }
- virtual int av_write_frame (AVFormatContext *s, AVPacket *pkt) { return ::av_write_frame(s, pkt); }
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,43,0)
-- // API added on: 2009-12-13
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return ::av_metadata_set2(pm, key, value, flags); }
--#elif LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,31,0)
-- // API added on: 2009-03-01
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return ::av_metadata_set(pm, key, value); }
--#else
-- virtual int av_metadata_set2(AVMetadata **pm, const char *key, const char *value, int flags) { return -1; }
--#endif
-
- // DLL faking.
- virtual bool ResolveExports() { return true; }
-@@ -218,108 +173,78 @@ class DllAvFormat : public DllDynamic, DllAvFormatInterface
-
- DEFINE_METHOD0(void, av_register_all_dont_call)
- DEFINE_METHOD1(AVInputFormat*, av_find_input_format, (const char *p1))
-- DEFINE_METHOD1(int, url_feof, (ByteIOContext *p1))
-- DEFINE_METHOD4(AVMetadataTag*, av_metadata_get, (AVMetadata *p1, const char *p2, const AVMetadataTag *p3, int p4))
-- DEFINE_METHOD1(void, av_close_input_file, (AVFormatContext *p1))
-- DEFINE_METHOD1(void, av_close_input_stream, (AVFormatContext *p1))
-+ DEFINE_METHOD1(int, url_feof, (AVIOContext *p1))
-+ DEFINE_METHOD1(void, avformat_close_input, (AVFormatContext **p1))
- DEFINE_METHOD1(int, av_read_play, (AVFormatContext *p1))
- DEFINE_METHOD1(int, av_read_pause, (AVFormatContext *p1))
- DEFINE_METHOD1(void, av_read_frame_flush, (AVFormatContext *p1))
- DEFINE_FUNC_ALIGNED2(int, __cdecl, av_read_frame, AVFormatContext *, AVPacket *)
- DEFINE_FUNC_ALIGNED4(int, __cdecl, av_seek_frame, AVFormatContext*, int, int64_t, int)
-- DEFINE_FUNC_ALIGNED1(int, __cdecl, av_find_stream_info_dont_call, AVFormatContext*)
-- DEFINE_FUNC_ALIGNED5(int, __cdecl, av_open_input_file, AVFormatContext**, const char *, AVInputFormat *, int, AVFormatParameters *)
-- DEFINE_FUNC_ALIGNED5(int,__cdecl, av_open_input_stream, AVFormatContext **, ByteIOContext *, const char *, AVInputFormat *, AVFormatParameters *)
-+ DEFINE_FUNC_ALIGNED2(int, __cdecl, avformat_find_stream_info_dont_call, AVFormatContext*, AVDictionary **)
-+ DEFINE_FUNC_ALIGNED4(int, __cdecl, avformat_open_input, AVFormatContext **, const char *, AVInputFormat *, AVDictionary **)
- DEFINE_FUNC_ALIGNED2(AVInputFormat*, __cdecl, av_probe_input_format, AVProbeData*, int)
- DEFINE_FUNC_ALIGNED3(AVInputFormat*, __cdecl, av_probe_input_format2, AVProbeData*, int, int*)
-- DEFINE_FUNC_ALIGNED6(int, __cdecl, av_probe_input_buffer, ByteIOContext *, AVInputFormat **, const char *, void *, unsigned int, unsigned int)
-- DEFINE_FUNC_ALIGNED3(int, __cdecl, get_buffer, ByteIOContext*, unsigned char *, int)
-- DEFINE_FUNC_ALIGNED3(int, __cdecl, get_partial_buffer, ByteIOContext*, unsigned char *, int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_byte, ByteIOContext*, int)
-- DEFINE_FUNC_ALIGNED3(void, __cdecl, put_buffer, ByteIOContext*, const unsigned char *, int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be24, ByteIOContext*, unsigned int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be32, ByteIOContext*, unsigned int)
-- DEFINE_FUNC_ALIGNED2(void, __cdecl, put_be16, ByteIOContext*, unsigned int)
-- DEFINE_METHOD1(void, url_set_interrupt_cb, (URLInterruptCB *p1))
-- DEFINE_METHOD8(int, init_put_byte, (ByteIOContext *p1, unsigned char *p2, int p3, int p4, void *p5,
-+ DEFINE_FUNC_ALIGNED6(int, __cdecl, av_probe_input_buffer, AVIOContext *, AVInputFormat **, const char *, void *, unsigned int, unsigned int)
-+ DEFINE_FUNC_ALIGNED3(int, __cdecl, avio_read, AVIOContext*, unsigned char *, int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_w8, AVIOContext*, int)
-+ DEFINE_FUNC_ALIGNED3(void, __cdecl, avio_write, AVIOContext*, const unsigned char *, int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb24, AVIOContext*, unsigned int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb32, AVIOContext*, unsigned int)
-+ DEFINE_FUNC_ALIGNED2(void, __cdecl, avio_wb16, AVIOContext*, unsigned int)
-+ DEFINE_METHOD7(AVIOContext *, avio_alloc_context, (unsigned char *p1, int p2, int p3, void *p4,
-+ int (*p5)(void *opaque, uint8_t *buf, int buf_size),
- int (*p6)(void *opaque, uint8_t *buf, int buf_size),
-- int (*p7)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t (*p8)(void *opaque, offset_t offset, int whence)))
-- DEFINE_METHOD4(void, dump_format, (AVFormatContext *p1, int p2, const char *p3, int p4))
-- DEFINE_METHOD2(int, url_fdopen, (ByteIOContext **p1, URLContext *p2))
-- DEFINE_METHOD3(int, url_fopen, (ByteIOContext **p1, const char *p2, int p3))
-- DEFINE_METHOD1(int, url_fclose, (ByteIOContext *p1))
-- DEFINE_METHOD1(int, url_open_dyn_buf, (ByteIOContext **p1))
-- DEFINE_METHOD2(int, url_close_dyn_buf, (ByteIOContext *p1, uint8_t **p2))
-- DEFINE_METHOD3(offset_t, url_fseek, (ByteIOContext *p1, offset_t p2, int p3))
-+ offset_t (*p7)(void *opaque, offset_t offset, int whence)))
-+ DEFINE_METHOD4(void, av_dump_format, (AVFormatContext *p1, int p2, const char *p3, int p4))
-+ DEFINE_METHOD3(int, avio_open, (AVIOContext **p1, const char *p2, int p3))
-+ DEFINE_METHOD1(int, avio_close, (AVIOContext *p1))
-+ DEFINE_METHOD1(int, avio_open_dyn_buf, (AVIOContext **p1))
-+ DEFINE_METHOD2(int, avio_close_dyn_buf, (AVIOContext *p1, uint8_t **p2))
-+ DEFINE_METHOD3(offset_t, avio_seek, (AVIOContext *p1, offset_t p2, int p3))
- DEFINE_METHOD0(AVFormatContext *, avformat_alloc_context)
-- DEFINE_METHOD2(AVStream *, av_new_stream, (AVFormatContext *p1, int p2))
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- DEFINE_METHOD3(AVOutputFormat *, guess_format, (const char *p1, const char *p2, const char *p3))
--#else
-+ DEFINE_METHOD2(AVStream *, avformat_new_stream, (AVFormatContext *p1, AVCodec *p2))
- DEFINE_METHOD3(AVOutputFormat *, av_guess_format, (const char *p1, const char *p2, const char *p3))
--#endif
-- DEFINE_METHOD2(int, av_set_parameters, (AVFormatContext *p1, AVFormatParameters *p2));
-- DEFINE_METHOD7(ByteIOContext *, av_alloc_put_byte, (unsigned char *p1, int p2, int p3, void *p4,
-- int(*p5)(void *opaque, uint8_t *buf, int buf_size),
-- int(*p6)(void *opaque, uint8_t *buf, int buf_size),
-- offset_t(*p7)(void *opaque, offset_t offset, int whence)))
-- DEFINE_METHOD1(int, av_write_header , (AVFormatContext *p1))
-+ DEFINE_METHOD2(int, avformat_write_header , (AVFormatContext *p1, AVDictionary **p2))
- DEFINE_METHOD1(int, av_write_trailer, (AVFormatContext *p1))
- DEFINE_METHOD2(int, av_write_frame , (AVFormatContext *p1, AVPacket *p2))
-- DEFINE_METHOD4(int, av_metadata_set2, (AVMetadata **p1, const char *p2, const char *p3, int p4));
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD_RENAME(av_register_all, av_register_all_dont_call)
- RESOLVE_METHOD(av_find_input_format)
- RESOLVE_METHOD(url_feof)
-- RESOLVE_METHOD(av_metadata_get)
-- RESOLVE_METHOD(av_close_input_file)
-- RESOLVE_METHOD(av_close_input_stream)
-+ RESOLVE_METHOD(avformat_close_input)
- RESOLVE_METHOD(av_read_frame)
- RESOLVE_METHOD(av_read_play)
- RESOLVE_METHOD(av_read_pause)
-- RESOLVE_METHOD_RENAME(ff_read_frame_flush, av_read_frame_flush)
-+ RESOLVE_METHOD(av_read_frame_flush)
- RESOLVE_METHOD(av_seek_frame)
-- RESOLVE_METHOD_RENAME(av_find_stream_info, av_find_stream_info_dont_call)
-- RESOLVE_METHOD(av_open_input_file)
-- RESOLVE_METHOD(url_set_interrupt_cb)
-- RESOLVE_METHOD(av_open_input_stream)
-- RESOLVE_METHOD(init_put_byte)
-+ RESOLVE_METHOD_RENAME(avformat_find_stream_info, avformat_find_stream_info_dont_call)
-+ RESOLVE_METHOD(avformat_open_input)
-+ RESOLVE_METHOD(avio_alloc_context)
- RESOLVE_METHOD(av_probe_input_format)
- RESOLVE_METHOD(av_probe_input_format2)
- RESOLVE_METHOD(av_probe_input_buffer)
-- RESOLVE_METHOD(dump_format)
-- RESOLVE_METHOD(url_fdopen)
-- RESOLVE_METHOD(url_fopen)
-- RESOLVE_METHOD(url_fclose)
-- RESOLVE_METHOD(url_open_dyn_buf)
-- RESOLVE_METHOD(url_close_dyn_buf)
-- RESOLVE_METHOD(url_fseek)
-- RESOLVE_METHOD(get_buffer)
-- RESOLVE_METHOD(get_partial_buffer)
-- RESOLVE_METHOD(put_byte)
-- RESOLVE_METHOD(put_buffer)
-- RESOLVE_METHOD(put_be24)
-- RESOLVE_METHOD(put_be32)
-- RESOLVE_METHOD(put_be16)
-+ RESOLVE_METHOD(av_dump_format)
-+ RESOLVE_METHOD(avio_open)
-+ RESOLVE_METHOD(avio_close)
-+ RESOLVE_METHOD(avio_open_dyn_buf)
-+ RESOLVE_METHOD(avio_close_dyn_buf)
-+ RESOLVE_METHOD(avio_seek)
-+ RESOLVE_METHOD(avio_read)
-+ RESOLVE_METHOD(avio_w8)
-+ RESOLVE_METHOD(avio_write)
-+ RESOLVE_METHOD(avio_wb24)
-+ RESOLVE_METHOD(avio_wb32)
-+ RESOLVE_METHOD(avio_wb16)
- RESOLVE_METHOD(avformat_alloc_context)
-- RESOLVE_METHOD(av_new_stream)
--#if LIBAVFORMAT_VERSION_INT < (52<<16 | 45<<8)
-- RESOLVE_METHOD(guess_format)
--#else
-+ RESOLVE_METHOD(avformat_new_stream)
- RESOLVE_METHOD(av_guess_format)
--#endif
-- RESOLVE_METHOD(av_set_parameters)
-- RESOLVE_METHOD(av_alloc_put_byte)
-- RESOLVE_METHOD(av_write_header)
-+ RESOLVE_METHOD(avformat_write_header)
- RESOLVE_METHOD(av_write_trailer)
- RESOLVE_METHOD(av_write_frame)
-- RESOLVE_METHOD(av_metadata_set2)
- END_METHOD_RESOLVE()
-
- /* dependencies of libavformat */
- DllAvCodec m_dllAvCodec;
-- // DllAvCore loaded implicitely by m_dllAvCodec
- // DllAvUtil loaded implicitely by m_dllAvCodec
-
- public:
-@@ -328,10 +253,10 @@ public:
- CSingleLock lock(DllAvCodec::m_critSection);
- av_register_all_dont_call();
- }
-- int av_find_stream_info(AVFormatContext *ic)
-+ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
- {
- CSingleLock lock(DllAvCodec::m_critSection);
-- return(av_find_stream_info_dont_call(ic));
-+ return avformat_find_stream_info_dont_call(ic, options);
- }
-
- virtual bool Load()
-diff --git a/lib/DllAvUtil.h b/lib/DllAvUtil.h
-index b8bb2d6..2331777 100644
---- a/lib/DllAvUtil.h
-+++ b/lib/DllAvUtil.h
-@@ -69,6 +69,7 @@ extern "C" {
- #include "libavutil/opt.h"
- #include "libavutil/mem.h"
- #include "libavutil/fifo.h"
-+ #include "libavutil/samplefmt.h"
- #endif
- }
-
-@@ -93,7 +94,7 @@ public:
- virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)=0;
- virtual const AVCRC* av_crc_get_table(AVCRCId crc_id)=0;
- virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)=0;
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)=0;
-+ virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags)=0;
- virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) = 0;
- virtual void av_fifo_free(AVFifoBuffer *f) = 0;
- virtual void av_fifo_reset(AVFifoBuffer *f) = 0;
-@@ -101,10 +102,13 @@ public:
- virtual int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)) = 0;
- virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)) = 0;
- virtual char *av_strdup(const char *s)=0;
-+ virtual int av_get_bytes_per_sample(enum AVSampleFormat p1) = 0;
-+ virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) = 0;
-+ virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)=0;
-+ virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) = 0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
--
-+#if defined (USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
- // Use direct layer
- class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
- {
-@@ -121,12 +125,7 @@ public:
- virtual int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) { return ::av_rescale_q(a, bq, cq); }
- virtual const AVCRC* av_crc_get_table(AVCRCId crc_id) { return ::av_crc_get_table(crc_id); }
- virtual uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length) { return ::av_crc(ctx, crc, buffer, length); }
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,7,0)
-- // API added on: 2008-12-16
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) { return ::av_set_string3(obj, name, val, alloc, o_out); }
--#else
-- virtual int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) { return AVERROR(ENOENT); }
--#endif
-+ virtual int av_opt_set(void *obj, const char *name, const char *val, int search_flags) { return ::av_opt_set(obj, name, val, search_flags); }
- virtual AVFifoBuffer *av_fifo_alloc(unsigned int size) {return ::av_fifo_alloc(size); }
- virtual void av_fifo_free(AVFifoBuffer *f) { ::av_fifo_free(f); }
- virtual void av_fifo_reset(AVFifoBuffer *f) { ::av_fifo_reset(f); }
-@@ -136,6 +135,12 @@ public:
- virtual int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
- { return ::av_fifo_generic_write(f, src, size, func); }
- virtual char *av_strdup(const char *s) { return ::av_strdup(s); }
-+ virtual int av_get_bytes_per_sample(enum AVSampleFormat p1)
-+ { return ::av_get_bytes_per_sample(p1); }
-+ virtual AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags){ return ::av_dict_get(m, key, prev, flags); }
-+ virtual int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) { return ::av_dict_set(pm, key, value, flags); }
-+ virtual int av_samples_get_buffer_size (int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align)
-+ { return ::av_samples_get_buffer_size(linesize, nb_channels, nb_samples, sample_fmt, align); }
-
- // DLL faking.
- virtual bool ResolveExports() { return true; }
-@@ -164,7 +169,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
- DEFINE_METHOD3(int64_t, av_rescale_q, (int64_t p1, AVRational p2, AVRational p3));
- DEFINE_METHOD1(const AVCRC*, av_crc_get_table, (AVCRCId p1))
- DEFINE_METHOD4(uint32_t, av_crc, (const AVCRC *p1, uint32_t p2, const uint8_t *p3, size_t p4));
-- DEFINE_METHOD5(int, av_set_string3, (void *p1, const char *p2, const char *p3, int p4, const AVOption **p5));
-+ DEFINE_METHOD4(int, av_opt_set, (void *p1, const char *p2, const char *p3, int p4));
- DEFINE_METHOD1(AVFifoBuffer*, av_fifo_alloc, (unsigned int p1))
- DEFINE_METHOD1(void, av_fifo_free, (AVFifoBuffer *p1))
- DEFINE_METHOD1(void, av_fifo_reset, (AVFifoBuffer *p1))
-@@ -172,6 +177,10 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
- DEFINE_METHOD4(int, av_fifo_generic_read, (AVFifoBuffer *p1, void *p2, int p3, void (*p4)(void*, void*, int)))
- DEFINE_METHOD4(int, av_fifo_generic_write, (AVFifoBuffer *p1, void *p2, int p3, int (*p4)(void*, void*, int)))
- DEFINE_METHOD1(char*, av_strdup, (const char *p1))
-+ DEFINE_METHOD1(int, av_get_bytes_per_sample, (enum AVSampleFormat p1))
-+ DEFINE_METHOD4(AVDictionaryEntry *, av_dict_get, (AVDictionary *p1, const char *p2, const AVDictionaryEntry *p3, int p4))
-+ DEFINE_METHOD4(int, av_dict_set, (AVDictionary **p1, const char *p2, const char *p3, int p4));
-+ DEFINE_METHOD5(int, av_samples_get_buffer_size, (int *p1, int p2, int p3, enum AVSampleFormat p4, int p5))
-
- public:
- BEGIN_METHOD_RESOLVE()
-@@ -185,7 +194,7 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
- RESOLVE_METHOD(av_rescale_q)
- RESOLVE_METHOD(av_crc_get_table)
- RESOLVE_METHOD(av_crc)
-- RESOLVE_METHOD(av_set_string3)
-+ RESOLVE_METHOD(av_opt_set)
- RESOLVE_METHOD(av_fifo_alloc)
- RESOLVE_METHOD(av_fifo_free)
- RESOLVE_METHOD(av_fifo_reset)
-@@ -193,6 +202,10 @@ class DllAvUtilBase : public DllDynamic, DllAvUtilInterface
- RESOLVE_METHOD(av_fifo_generic_read)
- RESOLVE_METHOD(av_fifo_generic_write)
- RESOLVE_METHOD(av_strdup)
-+ RESOLVE_METHOD(av_get_bytes_per_sample)
-+ RESOLVE_METHOD(av_dict_get)
-+ RESOLVE_METHOD(av_dict_set)
-+ RESOLVE_METHOD(av_samples_get_buffer_size)
- END_METHOD_RESOLVE()
- };
-
-diff --git a/lib/DllPostProc.h b/lib/DllPostProc.h
-index b09a3f6..5465601 100644
---- a/lib/DllPostProc.h
-+++ b/lib/DllPostProc.h
-@@ -87,7 +87,7 @@ public:
- virtual void pp_free_context(pp_context *ppContext)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // We call directly.
- class DllPostProc : public DllDynamic, DllPostProcInterface
-diff --git a/lib/DllSwResample.h b/lib/DllSwResample.h
-new file mode 100644
-index 0000000..8a99072
---- /dev/null
-+++ b/lib/DllSwResample.h
-@@ -0,0 +1,87 @@
-+#pragma once
-+/*
-+ * Copyright (C) 2005-2010 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#if (defined HAVE_CONFIG_H) && (!defined WIN32)
-+ #include "config.h"
-+#endif
-+#include "DynamicDll.h"
-+
-+extern "C" {
-+#ifndef HAVE_MMX
-+#define HAVE_MMX
-+#endif
-+#ifndef __STDC_CONSTANT_MACROS
-+#define __STDC_CONSTANT_MACROS
-+#endif
-+#ifndef __GNUC__
-+#pragma warning(disable:4244)
-+#endif
-+#if (defined USE_EXTERNAL_FFMPEG)
-+ #include
-+#else
-+ #include "libswresample/swresample.h"
-+#endif
-+}
-+
-+
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-+
-+// Use direct mapping
-+class DllSwResample : public DllDynamic
-+{
-+public:
-+ virtual ~DllSwResample() {}
-+
-+ // DLL faking.
-+ virtual bool ResolveExports() { return true; }
-+ virtual bool Load() {
-+ CLog::Log(LOGDEBUG, "DllAvFormat: Using libswresample system library");
-+ return true;
-+ }
-+ virtual void Unload() {}
-+};
-+
-+#else
-+
-+class DllSwResample : public DllDynamic
-+{
-+ DECLARE_DLL_WRAPPER(DllSwResample, DLL_PATH_LIBSWRESAMPLE)
-+
-+ LOAD_SYMBOLS()
-+
-+ BEGIN_METHOD_RESOLVE()
-+ END_METHOD_RESOLVE()
-+
-+ /* dependencies of libavformat */
-+ DllAvUtil m_dllAvUtil;
-+
-+public:
-+
-+ virtual bool Load()
-+ {
-+ if (!m_dllAvUtil.Load())
-+ return false;
-+ return DllDynamic::Load();
-+ }
-+};
-+
-+#endif
-diff --git a/lib/DllSwScale.h b/lib/DllSwScale.h
-index 0cfb654..0fe8184 100644
---- a/lib/DllSwScale.h
-+++ b/lib/DllSwScale.h
-@@ -92,7 +92,7 @@ public:
- virtual void sws_freeContext(struct SwsContext *context)=0;
- };
-
--#if (defined USE_EXTERNAL_FFMPEG)
-+#if (defined USE_EXTERNAL_FFMPEG) || (defined TARGET_DARWIN)
-
- // We call into this library directly.
- class DllSwScale : public DllDynamic, public DllSwScaleInterface
-diff --git a/lib/Makefile.in b/lib/Makefile.in
-index 3550582..2ea47fb 100644
---- a/lib/Makefile.in
-+++ b/lib/Makefile.in
-@@ -1,21 +1,18 @@
- ARCH=@ARCH@
-
-+AR=@AR@
- LD=@LD@
- CC=@CC@
- CXX=@CXX@
--SHELL=@SHELL@
--ifeq ($(findstring osx,$(ARCH)),osx)
--ifeq ($(findstring arm,$(ARCH)),arm)
--LDFLAGS=-arch armv7 -iphoneos_version_min 4.1 -bundle -undefined dynamic_lookup -read_only_relocs suppress
--else
--LDFLAGS=-bundle -undefined dynamic_lookup -read_only_relocs suppress
--endif
--else
--LDFLAGS=-shared -fPIC -rdynamic
--endif
- SYSDIR=@abs_top_srcdir@/system/players/dvdplayer
--WRAPPER=@abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper.o
--WRAPPER_MACH_ALIAS=@abs_top_srcdir@/xbmc/cores/DllLoader/exports/wrapper_mach_alias
-+
-+AVFORMAT_SO=avformat-53-$(ARCH).so
-+AVCODEC_SO=avcodec-53-$(ARCH).so
-+AVUTIL_SO=avutil-51-$(ARCH).so
-+AVFILTER_SO=avfilter-2-$(ARCH).so
-+SWSCALE_SO=swscale-2-$(ARCH).so
-+POSTPROC_SO=postproc-52-$(ARCH).so
-+SWRESAMPLE_SO=swresample-0-$(ARCH).so
-
- DIRS=
- ifneq (@USE_EXTERNAL_FFMPEG@,1)
-@@ -24,123 +21,55 @@ endif
-
- LIBS=
- ifneq (@USE_EXTERNAL_FFMPEG@,1)
-- LIBS+=avutil-50-$(ARCH).so \
-- avcodec-52-$(ARCH).so \
-- avcore-0-$(ARCH).so \
-- avformat-52-$(ARCH).so \
-- postproc-51-$(ARCH).so \
-- avfilter-1-$(ARCH).so \
-- swscale-0-$(ARCH).so
--endif
--
--ifneq (,$(findstring powerpc,$(ARCH)))
-- ARCH_DIR=ppc
--else
--ifeq ($(findstring arm,$(ARCH)),arm)
-- ARCH_DIR=arm
--else
-- ARCH_DIR=x86
--endif
-+ LIBS+=$(AVUTIL_SO) \
-+ $(AVCODEC_SO) \
-+ $(AVFORMAT_SO) \
-+ $(POSTPROC_SO) \
-+ $(AVFILTER_SO) \
-+ $(SWSCALE_SO) \
-+ $(SWRESAMPLE_SO)
- endif
-
- .PHONY: $(DIRS) codecs
-
--codecs: $(addprefix $(SYSDIR)/, $(LIBS));
--
--
--ifeq ($(findstring osx,$(ARCH)), osx)
--# Add -lbundle1.o for powerpc-osx
--ifeq ($(ARCH), powerpc-osx)
--BUNDLE1_O = -lbundle1.o
--endif
--
--$(SYSDIR)/avutil-50-$(ARCH).so: $(WRAPPER) ffmpeg/libavutil/libavutil.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavutil/*.o \
-- ffmpeg/libavutil/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avcodec-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavcodec/*.o \
-- ffmpeg/libavcodec/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avcore-0-$(ARCH).so: $(WRAPPER) ffmpeg/libavcore/libavcore.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavcore/*.o $(BUNDLE1_O)
--
--$(SYSDIR)/avformat-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavformat/libavformat.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavformat/*.o $(BUNDLE1_O)
--
--ifeq ($(findstring x86,$(ARCH_DIR)), x86)
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavfilter/$(ARCH_DIR)/*.o \
-- ffmpeg/libavfilter/*.o $(BUNDLE1_O)
--else # No libavfilter/ppc or libavfilter/arm
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libavfilter/*.o $(BUNDLE1_O)
--endif
-+ifneq ($(findstring osx,$(ARCH)), osx)
-
--ifneq ($(findstring arm,$(ARCH)), arm)
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libswscale/*.o \
-- ffmpeg/libswscale/$(ARCH_DIR)/*.o $(BUNDLE1_O)
--else # No ARM version of swscale available yet.
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libswscale/*.o
--endif
--
--$(SYSDIR)/postproc-51-$(ARCH).so: $(WRAPPER) ffmpeg/libpostproc/libpostproc.dylib
-- $(LD) $(LDFLAGS) -alias_list $(WRAPPER_MACH_ALIAS) -o $@ \
-- $(WRAPPER) ffmpeg/libpostproc/*.o $(BUNDLE1_O)
--
--ffmpeg/libavutil/libavutil.dylib : ffmpeg;
--ffmpeg/libavcodec/libavcodec.dylib : ffmpeg;
--ffmpeg/libavcore/libavcore.dylib : ffmpeg;
--ffmpeg/libavformat/libavformat.dylib : ffmpeg;
--ffmpeg/libavformat/libavfilter.dylib : ffmpeg;
--ffmpeg/libswscale/libswscale.dylib : ffmpeg;
--ffmpeg/libpostproc/libpostproc.dylib : ffmpeg;
--ffmpeg:
-- $(MAKE) -C $@
--
--else
-+codecs: $(addprefix $(SYSDIR)/, $(LIBS));
-
--$(SYSDIR)/avutil-50-$(ARCH).so: ffmpeg/libavutil/libavutil.so
-+$(SYSDIR)/$(AVUTIL_SO): ffmpeg/libavutil/libavutil.so
- cp ffmpeg/libavutil/libavutil.so $@
-
--$(SYSDIR)/avcodec-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.so
-+$(SYSDIR)/$(AVCODEC_SO): ffmpeg/libavcodec/libavcodec.so
- cp ffmpeg/libavcodec/libavcodec.so $@
-
--$(SYSDIR)/avcore-0-$(ARCH).so: $(WRAPPER) ffmpeg/libavcore/libavcore.so
-- cp ffmpeg/libavcore/libavcore.so $@
--
--$(SYSDIR)/avformat-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavformat/libavformat.so
-+$(SYSDIR)/$(AVFORMAT_SO): ffmpeg/libavformat/libavformat.so
- cp ffmpeg/libavformat/libavformat.so $@
-
--$(SYSDIR)/avfilter-1-$(ARCH).so: $(WRAPPER) ffmpeg/libavfilter/libavfilter.so
-+$(SYSDIR)/$(AVFILTER_SO): ffmpeg/libavfilter/libavfilter.so
- cp ffmpeg/libavfilter/libavfilter.so $@
-
--$(SYSDIR)/swscale-0-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.so
-+$(SYSDIR)/$(SWSCALE_SO): ffmpeg/libswscale/libswscale.so
- cp ffmpeg/libswscale/libswscale.so $@
-
--$(SYSDIR)/postproc-51-$(ARCH).so: $(WRAPPER) ffmpeg/libpostproc/libpostproc.so
-+$(SYSDIR)/$(POSTPROC_SO): ffmpeg/libpostproc/libpostproc.so
- cp ffmpeg/libpostproc/libpostproc.so $@
-
-+$(SYSDIR)/$(SWRESAMPLE_SO): ffmpeg/libswresample/libswresample.so
-+ cp ffmpeg/libswresample/libswresample.so $@
-+
- ffmpeg/libavutil/libavutil.so : ffmpeg;
- ffmpeg/libavcodec/libavcodec.so : ffmpeg;
--ffmpeg/libavcore/libavcore.so : ffmpeg;
- ffmpeg/libavformat/libavformat.so : ffmpeg;
- ffmpeg/libavfilter/libavfilter.so : ffmpeg;
- ffmpeg/libswscale/libswscale.so : ffmpeg;
- ffmpeg/libpostproc/libpostproc.so : ffmpeg;
-+ffmpeg/libswresample/libswresample.so : ffmpeg;
-+endif
-+
- ffmpeg:
- $(MAKE) -C $@
--
-+ifeq ($(findstring osx,$(ARCH)), osx)
-+ $(AR) d ffmpeg/libavcodec/libavcodec.a inverse.o
- endif
-
- clean:
-diff --git a/xbmc/DllPaths_generated.h.in b/xbmc/DllPaths_generated.h.in
-index a84dd52..10a7d87 100644
---- a/xbmc/DllPaths_generated.h.in
-+++ b/xbmc/DllPaths_generated.h.in
-@@ -74,13 +74,13 @@
- #define DLL_PATH_LIBMAD "@MAD_SONAME@"
-
- /* ffmpeg */
--#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-52-@ARCH@.so"
--#define DLL_PATH_LIBAVCORE "special://xbmcbin/system/players/dvdplayer/avcore-0-@ARCH@.so"
--#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-52-@ARCH@.so"
--#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-50-@ARCH@.so"
--#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-51-@ARCH@.so"
--#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-0-@ARCH@.so"
--#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-1-@ARCH@.so"
-+#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-53-@ARCH@.so"
-+#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-53-@ARCH@.so"
-+#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-51-@ARCH@.so"
-+#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-52-@ARCH@.so"
-+#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-2-@ARCH@.so"
-+#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-2-@ARCH@.so"
-+#define DLL_PATH_LIBSWRESAMPLE "special://xbmcbin/system/players/dvdplayer/swresample-0-@ARCH@.so"
-
- /* cdrip */
- #if defined(_LINUX) && !defined(__APPLE__)
-diff --git a/xbmc/DllPaths_win32.h b/xbmc/DllPaths_win32.h
-index d39e2ea..fbd75a4 100644
---- a/xbmc/DllPaths_win32.h
-+++ b/xbmc/DllPaths_win32.h
-@@ -58,13 +58,13 @@
- #define DLL_PATH_LIBRTMP "special://xbmcbin/system/players/dvdplayer/librtmp.dll"
-
- /* ffmpeg */
--#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-52.dll"
--#define DLL_PATH_LIBAVCORE "special://xbmcbin/system/players/dvdplayer/avcore-0.dll"
--#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-52.dll"
--#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-50.dll"
--#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-1.dll"
--#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-51.dll"
--#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-0.dll"
-+#define DLL_PATH_LIBAVCODEC "special://xbmcbin/system/players/dvdplayer/avcodec-53.dll"
-+#define DLL_PATH_LIBAVFORMAT "special://xbmcbin/system/players/dvdplayer/avformat-53.dll"
-+#define DLL_PATH_LIBAVUTIL "special://xbmcbin/system/players/dvdplayer/avutil-51.dll"
-+#define DLL_PATH_LIBAVFILTER "special://xbmcbin/system/players/dvdplayer/avfilter-2.dll"
-+#define DLL_PATH_LIBPOSTPROC "special://xbmcbin/system/players/dvdplayer/postproc-52.dll"
-+#define DLL_PATH_LIBSWSCALE "special://xbmcbin/system/players/dvdplayer/swscale-2.dll"
-+#define DLL_PATH_LIBSWRESAMPLE "special://xbmcbin/system/players/dvdplayer/swresample-0.dll"
-
- /* cdrip */
- #define DLL_PATH_LAME_ENC "special://xbmcbin/system/cdrip/lame_enc.dll"
-diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp
-index 1ec9805..bcedb0c 100644
---- a/xbmc/cdrip/EncoderFFmpeg.cpp
-+++ b/xbmc/cdrip/EncoderFFmpeg.cpp
-@@ -59,11 +59,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
-
- CStdString filename = URIUtils::GetFileName(strFile);
- AVOutputFormat *fmt = NULL;
--#if LIBAVFORMAT_VERSION_MAJOR < 52
-- fmt = m_dllAvFormat.guess_format(NULL, filename.c_str(), NULL);
--#else
- fmt = m_dllAvFormat.av_guess_format(NULL, filename.c_str(), NULL);
--#endif
- if (!fmt)
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Unable to guess the output format for the file %s", filename.c_str());
-@@ -82,7 +78,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
- }
-
- m_Format = m_dllAvFormat.avformat_alloc_context();
-- m_Format->pb = m_dllAvFormat.av_alloc_put_byte(m_BCBuffer, sizeof(m_BCBuffer), URL_RDONLY, this, NULL, MuxerReadPacket, NULL);
-+ m_Format->pb = m_dllAvFormat.avio_alloc_context(m_BCBuffer, sizeof(m_BCBuffer), AVIO_FLAG_READ, this, NULL, MuxerReadPacket, NULL);
- if (!m_Format->pb)
- {
- m_dllAvUtil.av_freep(&m_Format);
-@@ -93,17 +89,8 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
- m_Format->oformat = fmt;
- m_Format->bit_rate = g_guiSettings.GetInt("audiocds.bitrate") * 1000;
-
-- /* setup the muxer */
-- if (m_dllAvFormat.av_set_parameters(m_Format, NULL) != 0)
-- {
-- m_dllAvUtil.av_freep(&m_Format->pb);
-- m_dllAvUtil.av_freep(&m_Format);
-- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to set the muxer parameters");
-- return false;
-- }
--
- /* add a stream to it */
-- m_Stream = m_dllAvFormat.av_new_stream(m_Format, 1);
-+ m_Stream = m_dllAvFormat.avformat_new_stream(m_Format, codec);
- if (!m_Stream)
- {
- m_dllAvUtil.av_freep(&m_Format->pb);
-@@ -144,7 +131,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
- return false;
- }
-
-- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec))
-+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL))
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to open the codec");
- m_dllAvUtil.av_freep(&m_Stream);
-@@ -179,7 +166,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
- SetTag("encoder" , "XBMC FFmpeg Encoder");
-
- /* write the header */
-- if (m_dllAvFormat.av_write_header(m_Format) != 0)
-+ if (m_dllAvFormat.avformat_write_header(m_Format, NULL) != 0)
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to write the header");
- delete[] m_Buffer;
-@@ -194,7 +181,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
-
- void CEncoderFFmpeg::SetTag(const CStdString tag, const CStdString value)
- {
-- m_dllAvFormat.av_metadata_set2(&m_Format->metadata, tag.c_str(), value.c_str(), 0);
-+ m_dllAvUtil.av_dict_set(&m_Format->metadata, tag.c_str(), value.c_str(), 0);
- }
-
- int CEncoderFFmpeg::MuxerReadPacket(void *opaque, uint8_t *buf, int buf_size)
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
-index cebba1c..46fd47f 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
-@@ -29,10 +29,6 @@
-
- CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec()
- {
-- m_iBufferSize1 = 0;
-- m_pBuffer1 = (BYTE*)_aligned_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, 16);
-- memset(m_pBuffer1, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
--
- m_iBufferSize2 = 0;
- m_pBuffer2 = (BYTE*)_aligned_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE, 16);
- memset(m_pBuffer2, 0, AVCODEC_MAX_AUDIO_FRAME_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-@@ -45,11 +41,11 @@ CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec()
- m_channelMap[0] = PCM_INVALID;
- m_channels = 0;
- m_layout = 0;
-+ m_pFrame1 = NULL;
- }
-
- CDVDAudioCodecFFmpeg::~CDVDAudioCodecFFmpeg()
- {
-- _aligned_free(m_pBuffer1);
- _aligned_free(m_pBuffer2);
- Dispose();
- }
-@@ -59,12 +55,10 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
- AVCodec* pCodec;
- m_bOpenedCodec = false;
-
-- if (!m_dllAvCore.Load() || !m_dllAvUtil.Load() || !m_dllAvCodec.Load())
-+ if (!m_dllAvUtil.Load() || !m_dllAvCodec.Load())
- return false;
-
- m_dllAvCodec.avcodec_register_all();
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-- m_dllAvCodec.avcodec_get_context_defaults(m_pCodecContext);
-
- pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
- if (!pCodec)
-@@ -73,6 +67,7 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
- return false;
- }
-
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = 1;
-@@ -97,13 +92,14 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
- memcpy(m_pCodecContext->extradata, hints.extradata, hints.extrasize);
- }
-
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDAudioCodecFFmpeg::Open() Unable to open codec");
- Dispose();
- return false;
- }
-
-+ m_pFrame1 = m_dllAvCodec.avcodec_alloc_frame();
- m_bOpenedCodec = true;
- m_iSampleFormat = AV_SAMPLE_FMT_NONE;
- return true;
-@@ -111,6 +107,9 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
-
- void CDVDAudioCodecFFmpeg::Dispose()
- {
-+ if (m_pFrame1) m_dllAvUtil.av_free(m_pFrame1);
-+ m_pFrame1 = NULL;
-+
- if (m_pConvert)
- {
- m_dllAvCodec.av_audio_convert_free(m_pConvert);
-@@ -135,7 +134,7 @@ void CDVDAudioCodecFFmpeg::Dispose()
-
- int CDVDAudioCodecFFmpeg::Decode(BYTE* pData, int iSize)
- {
-- int iBytesUsed;
-+ int iBytesUsed, got_frame;
- if (!m_pCodecContext) return -1;
-
- m_iBufferSize1 = AVCODEC_MAX_AUDIO_FRAME_SIZE ;
-@@ -145,10 +144,17 @@ int CDVDAudioCodecFFmpeg::Decode(BYTE* pData, int iSize)
- m_dllAvCodec.av_init_packet(&avpkt);
- avpkt.data = pData;
- avpkt.size = iSize;
-- iBytesUsed = m_dllAvCodec.avcodec_decode_audio3( m_pCodecContext
-- , (int16_t*)m_pBuffer1
-- , &m_iBufferSize1
-+ iBytesUsed = m_dllAvCodec.avcodec_decode_audio4( m_pCodecContext
-+ , m_pFrame1
-+ , &got_frame
- , &avpkt);
-+ if (iBytesUsed < 0 || !got_frame)
-+ {
-+ m_iBufferSize1 = 0;
-+ m_iBufferSize2 = 0;
-+ return iBytesUsed;
-+ }
-+ m_iBufferSize1 = m_dllAvUtil.av_samples_get_buffer_size(NULL, m_pCodecContext->channels, m_pFrame1->nb_samples, m_pCodecContext->sample_fmt, 1);
-
- /* some codecs will attempt to consume more data than what we gave */
- if (iBytesUsed > iSize)
-@@ -184,9 +190,9 @@ int CDVDAudioCodecFFmpeg::Decode(BYTE* pData, int iSize)
- return iBytesUsed;
- }
-
-- const void *ibuf[6] = { m_pBuffer1 };
-+ const void *ibuf[6] = { m_pFrame1->data[0] };
- void *obuf[6] = { m_pBuffer2 };
-- int istr[6] = { m_dllAvCore.av_get_bits_per_sample_fmt(m_pCodecContext->sample_fmt)/8 };
-+ int istr[6] = { m_dllAvUtil.av_get_bytes_per_sample(m_pCodecContext->sample_fmt) };
- int ostr[6] = { 2 };
- int len = m_iBufferSize1 / istr[0];
- if(m_dllAvCodec.av_audio_convert(m_pConvert, obuf, ostr, ibuf, istr, len) < 0)
-@@ -208,7 +214,7 @@ int CDVDAudioCodecFFmpeg::GetData(BYTE** dst)
- {
- if(m_iBufferSize1)
- {
-- *dst = m_pBuffer1;
-+ *dst = m_pFrame1->data[0];
- return m_iBufferSize1;
- }
- if(m_iBufferSize2)
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
-index dbd4948..4c01499 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
-@@ -23,7 +23,6 @@
-
- #include "DVDAudioCodec.h"
- #include "DllAvCodec.h"
--#include "DllAvCore.h"
- #include "DllAvFormat.h"
- #include "DllAvUtil.h"
-
-@@ -51,7 +50,7 @@ protected:
- enum AVSampleFormat m_iSampleFormat;
- enum PCMChannels m_channelMap[PCM_MAX_CH + 1];
-
-- BYTE *m_pBuffer1;
-+ AVFrame* m_pFrame1;
- int m_iBufferSize1;
-
- BYTE *m_pBuffer2;
-@@ -64,7 +63,6 @@ protected:
- int64_t m_layout;
-
- DllAvCodec m_dllAvCodec;
-- DllAvCore m_dllAvCore;
- DllAvUtil m_dllAvUtil;
-
- void BuildChannelMap();
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp
-index 34e93a4..c0c3c06 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/DVDAudioCodecPassthroughFFmpeg.cpp
-@@ -79,11 +79,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
- /* get the muxer */
- AVOutputFormat *fOut = NULL;
-
--#if LIBAVFORMAT_VERSION_MAJOR < 52
-- fOut = m_dllAvFormat.guess_format(muxerName.c_str(), NULL, NULL);
--#else
- fOut = m_dllAvFormat.av_guess_format(muxerName.c_str(), NULL, NULL);
--#endif
- if (!fOut)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to get the FFmpeg %s muxer", muxerName.c_str());
-@@ -103,7 +99,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
- muxer.m_pFormat->oformat = fOut;
-
- /* allocate a put_byte struct so we can grab the output */
-- muxer.m_pFormat->pb = m_dllAvFormat.av_alloc_put_byte(muxer.m_BCBuffer, sizeof(muxer.m_BCBuffer), URL_RDONLY, &muxer, NULL, MuxerReadPacket, NULL);
-+ muxer.m_pFormat->pb = m_dllAvFormat.avio_alloc_context(muxer.m_BCBuffer, sizeof(muxer.m_BCBuffer), AVIO_FLAG_READ, &muxer, NULL, MuxerReadPacket, NULL);
- if (!muxer.m_pFormat->pb)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to allocate ByteIOContext");
-@@ -112,21 +108,10 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
- }
-
- /* this is streamed, no file, and ignore the index */
-- muxer.m_pFormat->pb->is_streamed = 1;
-+ muxer.m_pFormat->pb->seekable = 0;
- muxer.m_pFormat->flags |= AVFMT_NOFILE | AVFMT_FLAG_IGNIDX;
- muxer.m_pFormat->bit_rate = hints.bitrate;
-
-- /* setup the muxer */
-- if (m_dllAvFormat.av_set_parameters(muxer.m_pFormat, NULL) != 0)
-- {
-- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to set the %s muxer parameters", muxerName.c_str());
-- Dispose();
-- return false;
-- }
--
--#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,92,0)
-- // API added on: 2011-01-02
--
- /* While this is strictly only needed on big-endian systems, we do it on
- * both to avoid as much dead code as possible.
- * CoreAudio (at least on the cases we've seen) wants IEC 61937 in
-@@ -138,8 +123,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
- #endif
-
- /* request output of wanted endianness */
-- if (!fOut->priv_class || m_dllAvUtil.av_set_string3(muxer.m_pFormat->priv_data, "spdif_flags", spdifFlags, 0, NULL) != 0)
--#endif
-+ if (!fOut->priv_class || m_dllAvUtil.av_opt_set(muxer.m_pFormat->priv_data, "spdif_flags", spdifFlags, 0) != 0)
- {
- #if defined(WORDS_BIGENDIAN) && !defined(__APPLE__)
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Unable to set big-endian stream mode (FFmpeg too old?), disabling passthrough");
-@@ -149,7 +133,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
- }
-
- /* add a stream to it */
-- muxer.m_pStream = m_dllAvFormat.av_new_stream(muxer.m_pFormat, 1);
-+ muxer.m_pStream = m_dllAvFormat.avformat_new_stream(muxer.m_pFormat, NULL);
- if (!muxer.m_pStream)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthroughFFmpeg::SetupMuxer - Failed to allocate AVStream context");
-@@ -159,8 +143,6 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
-
-
- /* set the stream's parameters */
-- muxer.m_pStream->stream_copy = 1;
--
- m_SampleRate = hints.samplerate;
- if(!m_SampleRate && hints.codec == CODEC_ID_AC3)
- m_SampleRate = 48000;
-@@ -176,7 +158,7 @@ bool CDVDAudioCodecPassthroughFFmpeg::SetupMuxer(CDVDStreamInfo &hints, CStdStri
- codec->extradata_size = hints.extrasize;
- memcpy(codec->extradata, hints.extradata, hints.extrasize);
-
-- muxer.m_WroteHeader = m_dllAvFormat.av_write_header(muxer.m_pFormat) == 0;
-+ muxer.m_WroteHeader = m_dllAvFormat.avformat_write_header(muxer.m_pFormat, NULL) == 0;
- if (!muxer.m_WroteHeader)
- {
- CLog::Log(LOGERROR, "CDVDAudioCodecPassthrough::SetupMuxer - Failed to write the frame header");
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp
-index 77d4b64..0189e65 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.cpp
-@@ -55,7 +55,7 @@ CDVDAudioEncoderFFmpeg::~CDVDAudioEncoderFFmpeg()
- bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels *channelMap, unsigned int bitsPerSample, unsigned int sampleRate)
- {
- Reset();
-- if (!channelMap || !m_dllAvUtil.Load() || !m_dllAvCore.Load() || !m_dllAvCodec.Load())
-+ if (!channelMap || !m_dllAvUtil.Load() || !m_dllAvCodec.Load())
- return false;
-
- m_dllAvCodec.avcodec_register_all();
-@@ -65,7 +65,7 @@ bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels
- return false;
-
- /* always assume 6 channels, 5.1... m_remap will give us what we want */
-- m_CodecCtx = m_dllAvCodec.avcodec_alloc_context();
-+ m_CodecCtx = m_dllAvCodec.avcodec_alloc_context3(codec);
- m_CodecCtx->bit_rate = AC3_ENCODE_BITRATE;
- m_CodecCtx->sample_rate = sampleRate;
- m_CodecCtx->channels = 6;
-@@ -104,7 +104,7 @@ bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels
- }
- }
-
-- if (m_dllAvCodec.avcodec_open(m_CodecCtx, codec))
-+ if (m_dllAvCodec.avcodec_open2(m_CodecCtx, codec, NULL))
- {
- m_dllAvUtil.av_freep(&m_CodecCtx);
- return false;
-@@ -149,7 +149,7 @@ bool CDVDAudioEncoderFFmpeg::Initialize(unsigned int channels, enum PCMChannels
-
- if (m_AudioConvert)
- m_TmpBuffer2 = new uint8_t[m_NeededFrames * m_CodecCtx->channels *
-- m_dllAvCore.av_get_bits_per_sample_fmt(m_CodecCtx->sample_fmt) / 8];
-+ m_dllAvUtil.av_get_bytes_per_sample(m_CodecCtx->sample_fmt)];
-
- return true;
- }
-@@ -186,7 +186,7 @@ int CDVDAudioEncoderFFmpeg::Encode(uint8_t *data, int size)
- void *convInBuf[] = { m_TmpBuffer };
- int convInStr[] = { m_BitsPerSample / 8 };
- void *convOutBuf[] = { m_TmpBuffer2 };
-- int convOutStr[] = { m_dllAvCore.av_get_bits_per_sample_fmt(m_CodecCtx->sample_fmt) / 8 };
-+ int convOutStr[] = { m_dllAvUtil.av_get_bytes_per_sample(m_CodecCtx->sample_fmt) };
- if (m_dllAvCodec.av_audio_convert(m_AudioConvert, convOutBuf, convOutStr,
- convInBuf, convInStr, m_NeededFrames * m_CodecCtx->channels) < 0) {
- CLog::Log(LOGERROR, "CDVDAudioEncoderFFmpeg: Audio conversion failed");
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h
-index 93bd2c7..40be42b 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Audio/Encoders/DVDAudioEncoderFFmpeg.h
-@@ -43,7 +43,6 @@ public:
- virtual int GetData(uint8_t **data);
- private:
- DllAvCodec m_dllAvCodec;
-- DllAvCore m_dllAvCore;
- DllAvUtil m_dllAvUtil;
-
- AVCodecContext *m_CodecCtx;
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp
-index 563ce78..238c855 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Overlay/DVDOverlayCodecFFmpeg.cpp
-@@ -49,7 +49,14 @@ bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &optio
-
- m_dllAvCodec.avcodec_register_all();
-
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-+ AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
-+ if (!pCodec)
-+ {
-+ CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec);
-+ return false;
-+ }
-+
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
-@@ -100,14 +107,7 @@ bool CDVDOverlayCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &optio
- delete[] parse_extra;
- }
-
-- AVCodec* pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
-- if (!pCodec)
-- {
-- CLog::Log(LOGDEBUG,"%s - Unable to find codec %d", __FUNCTION__, hints.codec);
-- return false;
-- }
--
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec");
- return false;
-@@ -134,19 +134,12 @@ void CDVDOverlayCodecFFmpeg::FreeSubtitle(AVSubtitle& sub)
- {
- for(unsigned i=0;i= (52<<10)
- if(sub.rects[i])
- {
- m_dllAvUtil.av_free(sub.rects[i]->pict.data[0]);
- m_dllAvUtil.av_free(sub.rects[i]->pict.data[1]);
- m_dllAvUtil.av_freep(&sub.rects[i]);
- }
--#else
-- if(sub.rects[i].bitmap)
-- m_dllAvUtil.av_freep(&sub.rects[i].bitmap);
-- if(m_Subtitle.rects[i].rgba_palette)
-- m_dllAvUtil.av_freep(&sub.rects[i].rgba_palette);
--#endif
- }
- if(sub.rects)
- m_dllAvUtil.av_freep(&sub.rects);
-@@ -294,7 +287,6 @@ CDVDOverlay* CDVDOverlayCodecFFmpeg::GetOverlay()
- overlay->source_width = m_width;
- overlay->source_height = m_height;
-
--#if LIBAVCODEC_VERSION_INT >= (52<<10)
- BYTE* s = rect.pict.data[0];
- BYTE* t = overlay->data;
- for(int i=0;idata;
-- for(int i=0;ilinesize;
-- }
--
-- memcpy(overlay->palette, rect.rgba_palette, rect.nb_colors*4);
--
-- m_dllAvUtil.av_freep(&rect.bitmap);
-- m_dllAvUtil.av_freep(&rect.rgba_palette);
--#endif
- m_SubtitleIndex++;
-
- return overlay;
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-index 637a371..7ac6b6b 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-@@ -123,12 +123,11 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
- CDVDVideoCodecFFmpeg::CDVDVideoCodecFFmpeg() : CDVDVideoCodec()
- {
- m_pCodecContext = NULL;
-- m_pConvertFrame = NULL;
- m_pFrame = NULL;
- m_pFilterGraph = NULL;
- m_pFilterIn = NULL;
- m_pFilterOut = NULL;
-- m_pFilterLink = NULL;
-+ m_pBufferRef = NULL;
-
- m_iPictureWidth = 0;
- m_iPictureHeight = 0;
-@@ -163,9 +162,13 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
- m_dllAvFilter.avfilter_register_all();
-
- m_bSoftware = hints.software;
-- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
-+
-+ m_formats.push_back(PIX_FMT_YUV420P);
-+ m_formats.push_back(PIX_FMT_YUVJ420P);
-+ m_formats.push_back(PIX_FMT_NONE); /* always add none to get a terminated list in ffmpeg world */
-
- pCodec = NULL;
-+ m_pCodecContext = NULL;
-
- if (hints.codec == CODEC_ID_H264)
- {
-@@ -196,6 +199,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Creating VDPAU(%ix%i, %d)",hints.width, hints.height, hints.codec);
- CVDPAU* vdp = new CVDPAU();
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->codec_id = hints.codec;
- m_pCodecContext->width = hints.width;
- m_pCodecContext->height = hints.height;
-@@ -207,7 +211,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
- break;
- }
-- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
-+ m_dllAvUtil.av_freep(&m_pCodecContext);
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Failed to get VDPAU device");
- vdp->Release();
- }
-@@ -226,21 +230,26 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Using codec: %s",pCodec->long_name ? pCodec->long_name : pCodec->name);
-
-+ if(m_pCodecContext == NULL)
-+ m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
-+
- m_pCodecContext->opaque = (void*)this;
- m_pCodecContext->debug_mv = 0;
- m_pCodecContext->debug = 0;
- m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
- m_pCodecContext->get_format = GetFormat;
- m_pCodecContext->codec_tag = hints.codec_tag;
-+ /* Only allow slice threading, since frame threading is more
-+ * sensitive to changes in frame sizes, and it causes crashes
-+ * during HW accell */
-+ m_pCodecContext->thread_type = FF_THREAD_SLICE;
-
- #if defined(__APPLE__) && defined(__arm__)
- // ffmpeg with enabled neon will crash and burn if this is enabled
- m_pCodecContext->flags &= CODEC_FLAG_EMU_EDGE;
- #else
- if (pCodec->id != CODEC_ID_H264 && pCodec->capabilities & CODEC_CAP_DR1
--#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,69,0)
- && pCodec->id != CODEC_ID_VP8
--#endif
- )
- m_pCodecContext->flags |= CODEC_FLAG_EMU_EDGE;
- #endif
-@@ -272,16 +281,16 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
- if (it->m_name == "surfaces")
- m_uSurfacesCount = std::atoi(it->m_value.c_str());
- else
-- m_dllAvUtil.av_set_string3(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0, NULL);
-+ m_dllAvUtil.av_opt_set(m_pCodecContext, it->m_name.c_str(), it->m_value.c_str(), 0);
- }
-
- int num_threads = std::min(8 /*MAX_THREADS*/, g_cpuInfo.getCPUCount());
- if( num_threads > 1 && !hints.software && m_pHardware == NULL // thumbnail extraction fails when run threaded
- && ( pCodec->id == CODEC_ID_H264
- || pCodec->id == CODEC_ID_MPEG4 ))
-- m_dllAvCodec.avcodec_thread_init(m_pCodecContext, num_threads);
-+ m_pCodecContext->thread_count = num_threads;
-
-- if (m_dllAvCodec.avcodec_open(m_pCodecContext, pCodec) < 0)
-+ if (m_dllAvCodec.avcodec_open2(m_pCodecContext, pCodec, NULL) < 0)
- {
- CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to open codec");
- return false;
-@@ -290,14 +299,7 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
- m_pFrame = m_dllAvCodec.avcodec_alloc_frame();
- if (!m_pFrame) return false;
-
-- if(pCodec->name)
-- m_name = CStdString("ff-") + pCodec->name;
-- else
-- m_name = "ffmpeg";
--
-- if(m_pHardware)
-- m_name += "-" + m_pHardware->Name();
--
-+ UpdateName();
- return true;
- }
-
-@@ -306,13 +308,6 @@ void CDVDVideoCodecFFmpeg::Dispose()
- if (m_pFrame) m_dllAvUtil.av_free(m_pFrame);
- m_pFrame = NULL;
-
-- if (m_pConvertFrame)
-- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- }
-- m_pConvertFrame = NULL;
--
- if (m_pCodecContext)
- {
- if (m_pCodecContext->codec) m_dllAvCodec.avcodec_close(m_pCodecContext);
-@@ -458,9 +453,6 @@ int CDVDVideoCodecFFmpeg::Decode(BYTE* pData, int iSize, double dts, double pts)
- return VC_ERROR;
- }
-
-- if (len != iSize && m_pCodecContext->skip_frame != AVDISCARD_NONREF)
-- CLog::Log(LOGWARNING, "%s - avcodec_decode_video didn't consume the full packet. size: %d, consumed: %d", __FUNCTION__, iSize, len);
--
- if (!iGotPicture)
- return VC_BUFFER;
-
-@@ -478,67 +470,32 @@ int CDVDVideoCodecFFmpeg::Decode(BYTE* pData, int iSize, double dts, double pts)
- if(m_pCodecContext->codec_id == CODEC_ID_H264)
- m_started = true;
-
-- if(m_pCodecContext->pix_fmt != PIX_FMT_YUV420P
-- && m_pCodecContext->pix_fmt != PIX_FMT_YUVJ420P
-- && m_pHardware == NULL)
-+ if(m_pHardware == NULL)
- {
-- if (!m_dllSwScale.IsLoaded() && !m_dllSwScale.Load())
-- return VC_ERROR;
-+ bool need_scale = std::find( m_formats.begin()
-+ , m_formats.end()
-+ , m_pCodecContext->pix_fmt) == m_formats.end();
-
-- if (!m_pConvertFrame)
-- {
-- // Allocate an AVFrame structure
-- m_pConvertFrame = (AVPicture*)m_dllAvUtil.av_mallocz(sizeof(AVPicture));
-- // Due to a bug in swsscale we need to allocate one extra line of data
-- if(m_dllAvCodec.avpicture_alloc( m_pConvertFrame
-- , PIX_FMT_YUV420P
-- , m_pCodecContext->width
-- , m_pCodecContext->height+1) < 0)
-- {
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- return VC_ERROR;
-- }
-- }
-+ bool need_reopen = false;
-+ if(!m_filters.Equals(m_filters_next))
-+ need_reopen = true;
-
-- // convert the picture
-- struct SwsContext *context = m_dllSwScale.sws_getContext(m_pCodecContext->width, m_pCodecContext->height,
-- m_pCodecContext->pix_fmt, m_pCodecContext->width, m_pCodecContext->height,
-- PIX_FMT_YUV420P, SWS_FAST_BILINEAR | SwScaleCPUFlags(), NULL, NULL, NULL);
--
-- if(context == NULL)
-+ if(m_pFilterIn)
- {
-- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::Decode - unable to obtain sws context for w:%i, h:%i, pixfmt: %i", m_pCodecContext->width, m_pCodecContext->height, m_pCodecContext->pix_fmt);
-- return VC_ERROR;
-+ if(m_pFilterIn->outputs[0]->format != m_pCodecContext->pix_fmt
-+ || m_pFilterIn->outputs[0]->w != m_pCodecContext->width
-+ || m_pFilterIn->outputs[0]->h != m_pCodecContext->height)
-+ need_reopen = true;
- }
-
-- m_dllSwScale.sws_scale(context
-- , m_pFrame->data
-- , m_pFrame->linesize
-- , 0
-- , m_pCodecContext->height
-- , m_pConvertFrame->data
-- , m_pConvertFrame->linesize);
--
-- m_dllSwScale.sws_freeContext(context);
-- }
-- else
-- {
-- // no need to convert, just free any existing convert buffers
-- if (m_pConvertFrame)
-+ // try to setup new filters
-+ if (need_reopen || (need_scale && m_pFilterGraph == NULL))
- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- }
-- }
-+ m_filters = m_filters_next;
-
-- // try to setup new filters
-- if (!m_filters.Equals(m_filters_next))
-- {
-- m_filters = m_filters_next;
-- if(FilterOpen(m_filters) < 0)
-- FilterClose();
-+ if(FilterOpen(m_filters, need_scale) < 0)
-+ FilterClose();
-+ }
- }
-
- int result;
-@@ -564,12 +521,6 @@ void CDVDVideoCodecFFmpeg::Reset()
- if (m_pHardware)
- m_pHardware->Reset();
-
-- if (m_pConvertFrame)
-- {
-- m_dllAvCodec.avpicture_free(m_pConvertFrame);
-- m_dllAvUtil.av_free(m_pConvertFrame);
-- m_pConvertFrame = NULL;
-- }
- m_filters = "";
- FilterClose();
- }
-@@ -579,10 +530,10 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture)
- pDvdVideoPicture->iWidth = m_pCodecContext->width;
- pDvdVideoPicture->iHeight = m_pCodecContext->height;
-
-- if(m_pFilterLink)
-+ if(m_pBufferRef)
- {
-- pDvdVideoPicture->iWidth = m_pFilterLink->cur_buf->video->w;
-- pDvdVideoPicture->iHeight = m_pFilterLink->cur_buf->video->h;
-+ pDvdVideoPicture->iWidth = m_pBufferRef->video->w;
-+ pDvdVideoPicture->iHeight = m_pBufferRef->video->h;
- }
-
- /* crop of 10 pixels if demuxer asked it */
-@@ -598,12 +549,8 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture)
-
- /* use variable in the frame */
- AVRational pixel_aspect = m_pCodecContext->sample_aspect_ratio;
-- if (m_pFilterLink)
--#ifdef HAVE_AVFILTERBUFFERREFVIDEOPROPS_SAMPLE_ASPECT_RATIO
-- pixel_aspect = m_pFilterLink->cur_buf->video->sample_aspect_ratio;
--#else
-- pixel_aspect = m_pFilterLink->cur_buf->video->pixel_aspect;
--#endif
-+ if (m_pBufferRef)
-+ pixel_aspect = m_pBufferRef->video->sample_aspect_ratio;
-
- if (pixel_aspect.num == 0)
- aspect_ratio = 0;
-@@ -632,8 +579,6 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture)
- pDvdVideoPicture->iFlags = DVP_FLAG_ALLOCATED;
- pDvdVideoPicture->iFlags |= m_pFrame->interlaced_frame ? DVP_FLAG_INTERLACED : 0;
- pDvdVideoPicture->iFlags |= m_pFrame->top_field_first ? DVP_FLAG_TOP_FIELD_FIRST: 0;
-- if(m_pCodecContext->pix_fmt == PIX_FMT_YUVJ420P)
-- pDvdVideoPicture->color_range = 1;
-
- pDvdVideoPicture->chroma_position = m_pCodecContext->chroma_sample_location;
- pDvdVideoPicture->color_primaries = m_pCodecContext->color_primaries;
-@@ -677,14 +622,6 @@ bool CDVDVideoCodecFFmpeg::GetPicture(DVDVideoPicture* pDvdVideoPicture)
- if(!GetPictureCommon(pDvdVideoPicture))
- return false;
-
-- if(m_pConvertFrame)
-- {
-- for (int i = 0; i < 4; i++)
-- pDvdVideoPicture->data[i] = m_pConvertFrame->data[i];
-- for (int i = 0; i < 4; i++)
-- pDvdVideoPicture->iLineSize[i] = m_pConvertFrame->linesize[i];
-- }
-- else
- {
- for (int i = 0; i < 4; i++)
- pDvdVideoPicture->data[i] = m_pFrame->data[i];
-@@ -693,20 +630,38 @@ bool CDVDVideoCodecFFmpeg::GetPicture(DVDVideoPicture* pDvdVideoPicture)
- }
-
- pDvdVideoPicture->iFlags |= pDvdVideoPicture->data[0] ? 0 : DVP_FLAG_DROPPED;
-- pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
- pDvdVideoPicture->extended_format = 0;
-+ pDvdVideoPicture->color_range = 0;
-+
-+ PixelFormat pix_fmt;
-+ if(m_pBufferRef)
-+ pix_fmt = (PixelFormat)m_pBufferRef->format;
-+ else
-+ pix_fmt = m_pCodecContext->pix_fmt;
-+
-+ switch(pix_fmt)
-+ {
-+ case PIX_FMT_YUVJ420P:
-+ pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
-+ pDvdVideoPicture->color_range = 1;
-+ break;
-+ default:
-+ pDvdVideoPicture->format = DVDVideoPicture::FMT_YUV420P;
-+ break;
-+ }
-
- return true;
- }
-
--int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters)
-+int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters, bool scale)
- {
- int result;
-+ AVBufferSinkParams *buffersink_params;
-
- if (m_pFilterGraph)
- FilterClose();
-
-- if (filters.IsEmpty())
-+ if (filters.IsEmpty() && !scale)
- return 0;
-
- if (!(m_pFilterGraph = m_dllAvFilter.avfilter_graph_alloc()))
-@@ -715,17 +670,8 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters)
- return -1;
- }
-
-- // CrHasher HACK (if an alternative becomes available use it!): In order to display the output
-- // produced by a combination of filters we insert "nullsink" as the last filter and we use
-- // its input pin as our output pin.
-- //
-- // input --> .. --> last_filter --> [in] nullsink [null] [in] --> output
-- // | |
-- // | |
-- // +------------------------+
-- //
- AVFilter* srcFilter = m_dllAvFilter.avfilter_get_by_name("buffer");
-- AVFilter* outFilter = m_dllAvFilter.avfilter_get_by_name("nullsink"); // should be last filter in the graph for now
-+ AVFilter* outFilter = m_dllAvFilter.avfilter_get_by_name("buffersink"); // should be last filter in the graph for now
-
- CStdString args;
-
-@@ -744,11 +690,19 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters)
- return result;
- }
-
-- if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, NULL/*nullsink=>NULL*/, m_pFilterGraph)) < 0)
-+ buffersink_params = m_dllAvFilter.av_buffersink_params_alloc();
-+ buffersink_params->pixel_fmts = &m_formats[0];
-+#ifdef FF_API_OLD_VSINK_API
-+ if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, (void*)buffersink_params->pixel_fmts, m_pFilterGraph)) < 0)
-+#else
-+ if ((result = m_dllAvFilter.avfilter_graph_create_filter(&m_pFilterOut, outFilter, "out", NULL, buffersink_params, m_pFilterGraph)) < 0)
-+#endif
- {
-+ m_dllAvUtil.av_freep(&buffersink_params);
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterOpen - avfilter_graph_create_filter: out");
- return result;
- }
-+ m_dllAvUtil.av_freep(&buffersink_params);
-
- if (!filters.empty())
- {
-@@ -794,6 +748,12 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const CStdString& filters)
-
- void CDVDVideoCodecFFmpeg::FilterClose()
- {
-+ if(m_pBufferRef)
-+ {
-+ m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef);
-+ m_pBufferRef = NULL;
-+ }
-+
- if (m_pFilterGraph)
- {
- m_dllAvFilter.avfilter_graph_free(&m_pFilterGraph);
-@@ -801,7 +761,6 @@ void CDVDVideoCodecFFmpeg::FilterClose()
- // Disposed by above code
- m_pFilterIn = NULL;
- m_pFilterOut = NULL;
-- m_pFilterLink = NULL;
- }
- }
-
-@@ -809,24 +768,9 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame)
- {
- int result, frames;
-
-- m_pFilterLink = m_pFilterOut->inputs[0];
--
- if (frame)
- {
--#if (defined USE_OLD_AV_VSRC_BUFFER_ADD_FRAME)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts, m_pCodecContext->sample_aspect_ratio);
--#else
--#if LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,13,0)
- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, 0);
--#elif LIBAVFILTER_VERSION_INT >= AV_VERSION_INT(2,7,0)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame);
--#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,3,0)
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts);
--#else
-- result = m_dllAvFilter.av_vsrc_buffer_add_frame(m_pFilterIn, frame, frame->pts, m_pCodecContext->sample_aspect_ratio);
--#endif
--#endif
--
- if (result < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - av_vsrc_buffer_add_frame");
-@@ -834,7 +778,13 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame)
- }
- }
-
-- if ((frames = m_dllAvFilter.avfilter_poll_frame(m_pFilterLink)) < 0)
-+ if(m_pBufferRef)
-+ {
-+ m_dllAvFilter.avfilter_unref_buffer(m_pBufferRef);
-+ m_pBufferRef = NULL;
-+ }
-+
-+ if ((frames = m_dllAvFilter.av_buffersink_poll_frame(m_pFilterOut)) < 0)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - avfilter_poll_frame");
- return VC_ERROR;
-@@ -842,19 +792,9 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame)
-
- if (frames > 0)
- {
-- if (m_pFilterLink->cur_buf)
-- {
-- m_dllAvFilter.avfilter_unref_buffer(m_pFilterLink->cur_buf);
-- m_pFilterLink->cur_buf = NULL;
-- }
--
-- if ((result = m_dllAvFilter.avfilter_request_frame(m_pFilterLink)) < 0)
-- {
-- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - avfilter_request_frame");
-- return VC_ERROR;
-- }
-
-- if (!m_pFilterLink->cur_buf)
-+ result = m_dllAvFilter.av_buffersink_get_buffer_ref(m_pFilterOut, &m_pBufferRef, 0);
-+ if(!m_pBufferRef)
- {
- CLog::Log(LOGERROR, "CDVDVideoCodecFFmpeg::FilterProcess - cur_buf");
- return VC_ERROR;
-@@ -865,11 +805,11 @@ int CDVDVideoCodecFFmpeg::FilterProcess(AVFrame* frame)
- else
- m_pFrame->repeat_pict = -(frames - 1);
-
-- m_pFrame->interlaced_frame = m_pFilterLink->cur_buf->video->interlaced;
-- m_pFrame->top_field_first = m_pFilterLink->cur_buf->video->top_field_first;
-+ m_pFrame->interlaced_frame = m_pBufferRef->video->interlaced;
-+ m_pFrame->top_field_first = m_pBufferRef->video->top_field_first;
-
-- memcpy(m_pFrame->linesize, m_pFilterLink->cur_buf->linesize, 4*sizeof(int));
-- memcpy(m_pFrame->data , m_pFilterLink->cur_buf->data , 4*sizeof(uint8_t*));
-+ memcpy(m_pFrame->linesize, m_pBufferRef->linesize, 4*sizeof(int));
-+ memcpy(m_pFrame->data , m_pBufferRef->data , 4*sizeof(uint8_t*));
-
- if(frames > 1)
- return VC_PICTURE;
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
-index 53890cb..b958509 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
-@@ -68,27 +68,36 @@ public:
- {
- SAFE_RELEASE(m_pHardware);
- m_pHardware = hardware;
-- m_name += "-";
-- m_name += m_pHardware->Name();
-+ UpdateName();
- }
-
- protected:
- static enum PixelFormat GetFormat(struct AVCodecContext * avctx, const PixelFormat * fmt);
-
-- int FilterOpen(const CStdString& filters);
-+ int FilterOpen(const CStdString& filters, bool scale);
- void FilterClose();
- int FilterProcess(AVFrame* frame);
-
-+ void UpdateName()
-+ {
-+ if(m_pCodecContext->codec->name)
-+ m_name = CStdString("ff-") + m_pCodecContext->codec->name;
-+ else
-+ m_name = "ffmpeg";
-+
-+ if(m_pHardware)
-+ m_name += "-" + m_pHardware->Name();
-+ }
-+
- AVFrame* m_pFrame;
- AVCodecContext* m_pCodecContext;
-
-- AVPicture* m_pConvertFrame;
- CStdString m_filters;
- CStdString m_filters_next;
- AVFilterGraph* m_pFilterGraph;
- AVFilterContext* m_pFilterIn;
- AVFilterContext* m_pFilterOut;
-- AVFilterLink* m_pFilterLink;
-+ AVFilterBufferRef* m_pBufferRef;
-
- int m_iPictureWidth;
- int m_iPictureHeight;
-@@ -109,4 +118,5 @@ protected:
- int m_iLastKeyframe;
- double m_dts;
- bool m_started;
-+ std::vector m_formats;
- };
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp
-index 0238864..c9f0650 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVDA.cpp
-@@ -525,8 +525,8 @@ const int avc_parse_nal_units(DllAvFormat *av_format_ctx,
- {
- while (!*(nal_start++));
- nal_end = avc_find_startcode(nal_start, end);
-- av_format_ctx->put_be32(pb, nal_end - nal_start);
-- av_format_ctx->put_buffer(pb, nal_start, nal_end - nal_start);
-+ av_format_ctx->avio_wb32(pb, nal_end - nal_start);
-+ av_format_ctx->avio_write(pb, nal_start, nal_end - nal_start);
- size += 4 + nal_end - nal_start;
- nal_start = nal_end;
- }
-@@ -537,14 +537,14 @@ const int avc_parse_nal_units_buf(DllAvUtil *av_util_ctx, DllAvFormat *av_format
- const uint8_t *buf_in, uint8_t **buf, int *size)
- {
- ByteIOContext *pb;
-- int ret = av_format_ctx->url_open_dyn_buf(&pb);
-+ int ret = av_format_ctx->avio_open_dyn_buf(&pb);
- if (ret < 0)
- return ret;
-
- avc_parse_nal_units(av_format_ctx, pb, buf_in, *size);
-
- av_util_ctx->av_freep(buf);
-- *size = av_format_ctx->url_close_dyn_buf(pb, buf);
-+ *size = av_format_ctx->avio_close_dyn_buf(pb, buf);
- return 0;
- }
-
-@@ -590,26 +590,26 @@ const int isom_write_avcc(DllAvUtil *av_util_ctx, DllAvFormat *av_format_ctx,
- }
- assert(sps);
-
-- av_format_ctx->put_byte(pb, 1); /* version */
-- av_format_ctx->put_byte(pb, sps[1]); /* profile */
-- av_format_ctx->put_byte(pb, sps[2]); /* profile compat */
-- av_format_ctx->put_byte(pb, sps[3]); /* level */
-- av_format_ctx->put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-- av_format_ctx->put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-+ av_format_ctx->avio_w8(pb, 1); /* version */
-+ av_format_ctx->avio_w8(pb, sps[1]); /* profile */
-+ av_format_ctx->avio_w8(pb, sps[2]); /* profile compat */
-+ av_format_ctx->avio_w8(pb, sps[3]); /* level */
-+ av_format_ctx->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-+ av_format_ctx->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
-- av_format_ctx->put_be16(pb, sps_size);
-- av_format_ctx->put_buffer(pb, sps, sps_size);
-+ av_format_ctx->avio_wb16(pb, sps_size);
-+ av_format_ctx->avio_write(pb, sps, sps_size);
- if (pps)
- {
-- av_format_ctx->put_byte(pb, 1); /* number of pps */
-- av_format_ctx->put_be16(pb, pps_size);
-- av_format_ctx->put_buffer(pb, pps, pps_size);
-+ av_format_ctx->avio_w8(pb, 1); /* number of pps */
-+ av_format_ctx->avio_wb16(pb, pps_size);
-+ av_format_ctx->avio_write(pb, pps, pps_size);
- }
- av_util_ctx->av_free(start);
- }
- else
- {
-- av_format_ctx->put_buffer(pb, data, len);
-+ av_format_ctx->avio_write(pb, data, len);
- }
- }
- return 0;
-@@ -706,7 +706,7 @@ bool CDVDVideoCodecVDA::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
- }
-
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- {
- return false;
- }
-@@ -717,7 +717,7 @@ bool CDVDVideoCodecVDA::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the avcC atom data into extradata then write it into avcCData for VDADecoder
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
- // CFDataCreate makes a copy of extradata contents
- avcCData = CFDataCreate(kCFAllocatorDefault, (const uint8_t*)extradata, extrasize);
- // done with the converted extradata, we MUST free using av_free
-@@ -948,12 +948,12 @@ int CDVDVideoCodecVDA::Decode(BYTE* pData, int iSize, double dts, double pts)
- int demuxer_bytes;
- uint8_t *demuxer_content;
-
-- if(m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- {
- return VC_ERROR;
- }
- demuxer_bytes = avc_parse_nal_units(m_dllAvFormat, pb, pData, iSize);
-- demuxer_bytes = m_dllAvFormat->url_close_dyn_buf(pb, &demuxer_content);
-+ demuxer_bytes = m_dllAvFormat->avio_close_dyn_buf(pb, &demuxer_content);
- avc_demux = CFDataCreate(kCFAllocatorDefault, demuxer_content, demuxer_bytes);
- m_dllAvUtil->av_free(demuxer_content);
- }
-@@ -961,7 +961,7 @@ int CDVDVideoCodecVDA::Decode(BYTE* pData, int iSize, double dts, double pts)
- {
- // convert demuxer packet from 3 byte NAL sizes to 4 byte
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- uint32_t nal_size;
-@@ -970,14 +970,14 @@ int CDVDVideoCodecVDA::Decode(BYTE* pData, int iSize, double dts, double pts)
- while (nal_start < end)
- {
- nal_size = VDA_RB24(nal_start);
-- m_dllAvFormat->put_be32(pb, nal_size);
-+ m_dllAvFormat->avio_wb32(pb, nal_size);
- nal_start += 3;
-- m_dllAvFormat->put_buffer(pb, nal_start, nal_size);
-+ m_dllAvFormat->avio_write(pb, nal_start, nal_size);
- nal_start += nal_size;
- }
-
- uint8_t *demuxer_content;
-- int demuxer_bytes = m_dllAvFormat->url_close_dyn_buf(pb, &demuxer_content);
-+ int demuxer_bytes = m_dllAvFormat->avio_close_dyn_buf(pb, &demuxer_content);
- avc_demux = CFDataCreate(kCFAllocatorDefault, demuxer_content, demuxer_bytes);
- m_dllAvUtil->av_free(demuxer_content);
- }
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
-index 5f512fb..cca5318 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecVideoToolBox.cpp
-@@ -474,7 +474,7 @@ int quicktime_write_mp4_descr_length(DllAvFormat *av_format_ctx, ByteIOContext *
- {
- b |= 0x80;
- }
-- av_format_ctx->put_byte(pb, b);
-+ av_format_ctx->avio_w8(pb, b);
- }
-
- return numBytes;
-@@ -482,37 +482,37 @@ int quicktime_write_mp4_descr_length(DllAvFormat *av_format_ctx, ByteIOContext *
-
- void quicktime_write_esds(DllAvFormat *av_format_ctx, ByteIOContext *pb, quicktime_esds_t *esds)
- {
-- av_format_ctx->put_byte(pb, 0); // Version
-- av_format_ctx->put_be24(pb, 0); // Flags
-+ av_format_ctx->avio_w8(pb, 0); // Version
-+ av_format_ctx->avio_wb24(pb, 0); // Flags
-
- // elementary stream descriptor tag
-- av_format_ctx->put_byte(pb, 0x03);
-+ av_format_ctx->avio_w8(pb, 0x03);
- quicktime_write_mp4_descr_length(av_format_ctx, pb,
- 3 + 5 + (13 + 5 + esds->decoderConfigLen) + 3, false);
- // 3 bytes + 5 bytes for tag
-- av_format_ctx->put_be16(pb, esds->esid);
-- av_format_ctx->put_byte(pb, esds->stream_priority);
-+ av_format_ctx->avio_wb16(pb, esds->esid);
-+ av_format_ctx->avio_w8(pb, esds->stream_priority);
-
- // decoder configuration description tag
-- av_format_ctx->put_byte(pb, 0x04);
-+ av_format_ctx->avio_w8(pb, 0x04);
- quicktime_write_mp4_descr_length(av_format_ctx, pb,
- 13 + 5 + esds->decoderConfigLen, false);
- // 13 bytes + 5 bytes for tag
-- av_format_ctx->put_byte(pb, esds->objectTypeId); // objectTypeIndication
-- av_format_ctx->put_byte(pb, esds->streamType); // streamType
-- av_format_ctx->put_be24(pb, esds->bufferSizeDB); // buffer size
-- av_format_ctx->put_be32(pb, esds->maxBitrate); // max bitrate
-- av_format_ctx->put_be32(pb, esds->avgBitrate); // average bitrate
-+ av_format_ctx->avio_w8(pb, esds->objectTypeId); // objectTypeIndication
-+ av_format_ctx->avio_w8(pb, esds->streamType); // streamType
-+ av_format_ctx->avio_wb24(pb, esds->bufferSizeDB); // buffer size
-+ av_format_ctx->avio_wb32(pb, esds->maxBitrate); // max bitrate
-+ av_format_ctx->avio_wb32(pb, esds->avgBitrate); // average bitrate
-
- // decoder specific description tag
-- av_format_ctx->put_byte(pb, 0x05);
-+ av_format_ctx->avio_w8(pb, 0x05);
- quicktime_write_mp4_descr_length(av_format_ctx, pb, esds->decoderConfigLen, false);
-- av_format_ctx->put_buffer(pb, esds->decoderConfig, esds->decoderConfigLen);
-+ av_format_ctx->avio_write(pb, esds->decoderConfig, esds->decoderConfigLen);
-
- // sync layer configuration descriptor tag
-- av_format_ctx->put_byte(pb, 0x06); // tag
-- av_format_ctx->put_byte(pb, 0x01); // length
-- av_format_ctx->put_byte(pb, 0x7F); // no SL
-+ av_format_ctx->avio_w8(pb, 0x06); // tag
-+ av_format_ctx->avio_w8(pb, 0x01); // length
-+ av_format_ctx->avio_w8(pb, 0x7F); // no SL
-
- /* no IPI_DescrPointer */
- /* no IP_IdentificationDataSet */
-@@ -666,8 +666,8 @@ const int avc_parse_nal_units(DllAvFormat *av_format_ctx,
- {
- while (!*(nal_start++));
- nal_end = avc_find_startcode(nal_start, end);
-- av_format_ctx->put_be32(pb, nal_end - nal_start);
-- av_format_ctx->put_buffer(pb, nal_start, nal_end - nal_start);
-+ av_format_ctx->avio_wb32(pb, nal_end - nal_start);
-+ av_format_ctx->avio_write(pb, nal_start, nal_end - nal_start);
- size += 4 + nal_end - nal_start;
- nal_start = nal_end;
- }
-@@ -678,14 +678,14 @@ const int avc_parse_nal_units_buf(DllAvUtil *av_util_ctx, DllAvFormat *av_format
- const uint8_t *buf_in, uint8_t **buf, int *size)
- {
- ByteIOContext *pb;
-- int ret = av_format_ctx->url_open_dyn_buf(&pb);
-+ int ret = av_format_ctx->avio_open_dyn_buf(&pb);
- if (ret < 0)
- return ret;
-
- avc_parse_nal_units(av_format_ctx, pb, buf_in, *size);
-
- av_util_ctx->av_freep(buf);
-- *size = av_format_ctx->url_close_dyn_buf(pb, buf);
-+ *size = av_format_ctx->avio_close_dyn_buf(pb, buf);
- return 0;
- }
-
-@@ -770,26 +770,26 @@ const int isom_write_avcc(DllAvUtil *av_util_ctx, DllAvFormat *av_format_ctx,
- }
- assert(sps);
-
-- av_format_ctx->put_byte(pb, 1); /* version */
-- av_format_ctx->put_byte(pb, sps[1]); /* profile */
-- av_format_ctx->put_byte(pb, sps[2]); /* profile compat */
-- av_format_ctx->put_byte(pb, sps[3]); /* level */
-- av_format_ctx->put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-- av_format_ctx->put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-+ av_format_ctx->avio_w8(pb, 1); /* version */
-+ av_format_ctx->avio_w8(pb, sps[1]); /* profile */
-+ av_format_ctx->avio_w8(pb, sps[2]); /* profile compat */
-+ av_format_ctx->avio_w8(pb, sps[3]); /* level */
-+ av_format_ctx->avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
-+ av_format_ctx->avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
-
-- av_format_ctx->put_be16(pb, sps_size);
-- av_format_ctx->put_buffer(pb, sps, sps_size);
-+ av_format_ctx->avio_wb16(pb, sps_size);
-+ av_format_ctx->avio_write(pb, sps, sps_size);
- if (pps)
- {
-- av_format_ctx->put_byte(pb, 1); /* number of pps */
-- av_format_ctx->put_be16(pb, pps_size);
-- av_format_ctx->put_buffer(pb, pps, pps_size);
-+ av_format_ctx->avio_w8(pb, 1); /* number of pps */
-+ av_format_ctx->avio_wb16(pb, pps_size);
-+ av_format_ctx->avio_write(pb, pps, pps_size);
- }
- av_util_ctx->av_free(start);
- }
- else
- {
-- av_format_ctx->put_buffer(pb, data, len);
-+ av_format_ctx->avio_write(pb, data, len);
- }
- }
- return 0;
-@@ -1086,7 +1086,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o
- ByteIOContext *pb;
- quicktime_esds_t *esds;
-
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return false;
-
- esds = quicktime_set_esds(m_dllAvFormat, extradata, extrasize);
-@@ -1095,7 +1095,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the esds atom decoderConfig from extradata
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
- free(esds->decoderConfig);
- free(esds);
-
-@@ -1152,7 +1152,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o
- // NAL reformating to bitstream format required
-
- ByteIOContext *pb;
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return false;
-
- m_convert_bytestream = true;
-@@ -1161,7 +1161,7 @@ bool CDVDVideoCodecVideoToolBox::Open(CDVDStreamInfo &hints, CDVDCodecOptions &o
- // unhook from ffmpeg's extradata
- extradata = NULL;
- // extract the avcC atom data into extradata getting size into extrasize
-- extrasize = m_dllAvFormat->url_close_dyn_buf(pb, &extradata);
-+ extrasize = m_dllAvFormat->avio_close_dyn_buf(pb, &extradata);
-
- // check for interlaced and get number of ref frames
- if (!validate_avcC_spc(extradata, extrasize, &m_max_ref_frames))
-@@ -1301,17 +1301,17 @@ int CDVDVideoCodecVideoToolBox::Decode(BYTE* pData, int iSize, double dts, doubl
- if (m_convert_bytestream)
- {
- // convert demuxer packet from bytestream (AnnexB) to bitstream
-- if(m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if(m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- demux_size = avc_parse_nal_units(m_dllAvFormat, pb, pData, iSize);
-- demux_size = m_dllAvFormat->url_close_dyn_buf(pb, &demux_buff);
-+ demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff);
- sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size);
- }
- else if (m_convert_3byteTo4byteNALSize)
- {
- // convert demuxer packet from 3 byte NAL sizes to 4 byte
-- if (m_dllAvFormat->url_open_dyn_buf(&pb) < 0)
-+ if (m_dllAvFormat->avio_open_dyn_buf(&pb) < 0)
- return VC_ERROR;
-
- uint32_t nal_size;
-@@ -1320,13 +1320,13 @@ int CDVDVideoCodecVideoToolBox::Decode(BYTE* pData, int iSize, double dts, doubl
- while (nal_start < end)
- {
- nal_size = VDA_RB24(nal_start);
-- m_dllAvFormat->put_be32(pb, nal_size);
-+ m_dllAvFormat->avio_wb32(pb, nal_size);
- nal_start += 3;
-- m_dllAvFormat->put_buffer(pb, nal_start, nal_size);
-+ m_dllAvFormat->avio_write(pb, nal_start, nal_size);
- nal_start += nal_size;
- }
-
-- demux_size = m_dllAvFormat->url_close_dyn_buf(pb, &demux_buff);
-+ demux_size = m_dllAvFormat->avio_close_dyn_buf(pb, &demux_buff);
- sampleBuff = CreateSampleBufferFrom(m_fmt_desc, demux_buff, demux_size);
- }
- else
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
-index 18fe368..a4b8725 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
-@@ -223,7 +223,6 @@ int CDecoder::GetBuffer(AVCodecContext *avctx, AVFrame *pic)
- }
-
- pic->type = FF_BUFFER_TYPE_USER;
-- pic->age = 1;
- pic->data[0] = (uint8_t*)wrapper;
- pic->data[1] = NULL;
- pic->data[2] = NULL;
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-index 0e67af3..7379d60 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-@@ -1211,14 +1211,12 @@ int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
-
- if(pic->reference)
- {
-- pic->age = pA->ip_age[0];
- pA->ip_age[0]= pA->ip_age[1]+1;
- pA->ip_age[1]= 1;
- pA->b_age++;
- }
- else
- {
-- pic->age = pA->b_age;
- pA->ip_age[0]++;
- pA->ip_age[1]++;
- pA->b_age = 1;
-diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
-index 55138fa..31b6634 100644
---- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
-@@ -161,7 +161,7 @@ static TLS g_tls;
- #define g_demuxer (*((CDVDDemuxFFmpeg**)g_tls.Get()))
- #endif
-
--static int interrupt_cb(void)
-+static int interrupt_cb(void* unused)
- {
- if(g_demuxer && g_demuxer->Aborted())
- return 1;
-@@ -179,7 +179,7 @@ static int dvd_file_open(URLContext *h, const char *filename, int flags)
-
- static int dvd_file_read(void *h, uint8_t* buf, int size)
- {
-- if(interrupt_cb())
-+ if(interrupt_cb(NULL))
- return -1;
-
- CDVDInputStream* pInputStream = (CDVDInputStream*)h;
-@@ -193,7 +193,7 @@ static int dvd_file_write(URLContext *h, BYTE* buf, int size)
- */
- static offset_t dvd_file_seek(void *h, offset_t pos, int whence)
- {
-- if(interrupt_cb())
-+ if(interrupt_cb(NULL))
- return -1;
-
- CDVDInputStream* pInputStream = (CDVDInputStream*)h;
-@@ -237,6 +237,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- m_speed = DVD_PLAYSPEED_NORMAL;
- g_demuxer = this;
- m_program = UINT_MAX;
-+ const AVIOInterruptCB int_cb = { interrupt_cb, NULL };
-
- if (!pInput) return false;
-
-@@ -247,10 +248,6 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
-
- // register codecs
- m_dllAvFormat.av_register_all();
-- m_dllAvFormat.url_set_interrupt_cb(interrupt_cb);
--
-- // could be used for interupting ffmpeg while opening a file (eg internet streams)
-- // url_set_interrupt_cb(NULL);
-
- m_pInput = pInput;
- strFile = m_pInput->GetFileName();
-@@ -285,14 +282,14 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- // try mmsh, then mmst
- CStdString strFile2;
- strFile2.Format("mmsh://%s",strFile.substr(6,strFile.size()-6).c_str());
-- result = m_dllAvFormat.av_open_input_file(&m_pFormatContext, strFile2.c_str(), iformat, FFMPEG_FILE_BUFFER_SIZE, NULL);
-+ result = m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile2.c_str(), iformat, NULL);
- if (result < 0)
- {
- strFile = "mmst://";
- strFile += strFile2.Mid(7).c_str();
- }
- }
-- if (result < 0 && m_dllAvFormat.av_open_input_file(&m_pFormatContext, strFile.c_str(), iformat, FFMPEG_FILE_BUFFER_SIZE, NULL) < 0 )
-+ if (result < 0 && m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0 )
- {
- CLog::Log(LOGDEBUG, "Error, could not open file %s", strFile.c_str());
- Dispose();
-@@ -302,24 +299,16 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- else
- {
- unsigned char* buffer = (unsigned char*)m_dllAvUtil.av_malloc(FFMPEG_FILE_BUFFER_SIZE);
-- m_ioContext = m_dllAvFormat.av_alloc_put_byte(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, m_pInput, dvd_file_read, NULL, dvd_file_seek);
-+ m_ioContext = m_dllAvFormat.avio_alloc_context(buffer, FFMPEG_FILE_BUFFER_SIZE, 0, m_pInput, dvd_file_read, NULL, dvd_file_seek);
- m_ioContext->max_packet_size = m_pInput->GetBlockSize();
- if(m_ioContext->max_packet_size)
- m_ioContext->max_packet_size *= FFMPEG_FILE_BUFFER_SIZE / m_ioContext->max_packet_size;
-
- if(m_pInput->Seek(0, SEEK_POSSIBLE) == 0)
-- m_ioContext->is_streamed = 1;
-+ m_ioContext->seekable = 0;
-
- if( iformat == NULL )
- {
--#if defined(USE_EXTERNAL_FFMPEG) && LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52,98,0)
-- // API added on: 2011-02-09
-- // Old versions of ffmpeg do not have av_probe_input_format, so we need
-- // to always probe using the lower-level functions as well.
-- const bool legacyProbing = true;
--#else
-- const bool legacyProbing = false;
--#endif
- // let ffmpeg decide which demuxer we have to open
-
- bool trySPDIFonly = (m_pInput->GetContent() == "audio/x-spdif-compressed");
-@@ -332,7 +321,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- // want to probe for spdif (DTS or IEC 61937) compressed audio
- // specifically, or in case the file is a wav which may contain DTS or
- // IEC 61937 (e.g. ac3-in-wav) and we want to check for those formats.
-- if (legacyProbing || trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
-+ if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
- {
- AVProbeData pd;
- BYTE probe_buffer[FFMPEG_FILE_BUFFER_SIZE + AVPROBE_PADDING_SIZE];
-@@ -342,7 +331,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- pd.filename = strFile.c_str();
-
- // read data using avformat's buffers
-- pd.buf_size = m_dllAvFormat.get_buffer(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size);
-+ pd.buf_size = m_dllAvFormat.avio_read(m_ioContext, pd.buf, m_ioContext->max_packet_size ? m_ioContext->max_packet_size : m_ioContext->buffer_size);
- if (pd.buf_size <= 0)
- {
- CLog::Log(LOGERROR, "%s - error reading from input stream, %s", __FUNCTION__, strFile.c_str());
-@@ -351,10 +340,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- memset(pd.buf+pd.buf_size, 0, AVPROBE_PADDING_SIZE);
-
- // restore position again
-- m_dllAvFormat.url_fseek(m_ioContext , 0, SEEK_SET);
--
-- if (legacyProbing && !trySPDIFonly)
-- iformat = m_dllAvFormat.av_probe_input_format(&pd, 1);
-+ m_dllAvFormat.avio_seek(m_ioContext , 0, SEEK_SET);
-
- // the advancedsetting is for allowing the user to force outputting the
- // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode
-@@ -425,7 +411,10 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
-
-
- // open the demuxer
-- if (m_dllAvFormat.av_open_input_stream(&m_pFormatContext, m_ioContext, strFile.c_str(), iformat, NULL) < 0)
-+ m_pFormatContext = m_dllAvFormat.avformat_alloc_context();
-+ m_pFormatContext->pb = m_ioContext;
-+
-+ if (m_dllAvFormat.avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, NULL) < 0)
- {
- CLog::Log(LOGERROR, "%s - Error, could not open file %s", __FUNCTION__, strFile.c_str());
- Dispose();
-@@ -433,8 +422,11 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- }
- }
-
-+ // set the interrupt callback, appeared in libavformat 53.15.0
-+ m_pFormatContext->interrupt_callback = int_cb;
-+
- // analyse very short to speed up mjpeg playback start
-- if (iformat && (strcmp(iformat->name, "mjpeg") == 0) && m_ioContext->is_streamed)
-+ if (iformat && (strcmp(iformat->name, "mjpeg") == 0) && m_ioContext->seekable == 0)
- m_pFormatContext->max_analyze_duration = 500000;
-
- // we need to know if this is matroska or avi later
-@@ -448,8 +440,8 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- m_pFormatContext->max_analyze_duration = 500000;
-
-
-- CLog::Log(LOGDEBUG, "%s - av_find_stream_info starting", __FUNCTION__);
-- int iErr = m_dllAvFormat.av_find_stream_info(m_pFormatContext);
-+ CLog::Log(LOGDEBUG, "%s - avformat_find_stream_info starting", __FUNCTION__);
-+ int iErr = m_dllAvFormat.avformat_find_stream_info(m_pFormatContext, NULL);
- if (iErr < 0)
- {
- CLog::Log(LOGWARNING,"could not find codec parameters for %s", strFile.c_str());
-@@ -472,7 +464,7 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput)
- m_pFormatContext->flags |= AVFMT_FLAG_NONBLOCK;
-
- // print some extra information
-- m_dllAvFormat.dump_format(m_pFormatContext, 0, strFile.c_str(), 0);
-+ m_dllAvFormat.av_dump_format(m_pFormatContext, 0, strFile.c_str(), 0);
-
- UpdateCurrentPTS();
-
-@@ -511,20 +503,12 @@ void CDVDDemuxFFmpeg::Dispose()
-
- if (m_pFormatContext)
- {
-- if (m_ioContext)
-+ if (m_ioContext && m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
- {
-- if(m_pFormatContext->pb && m_pFormatContext->pb != m_ioContext)
-- {
-- CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
-- m_ioContext = m_pFormatContext->pb;
-- }
-- m_dllAvFormat.av_close_input_stream(m_pFormatContext);
-- if (m_ioContext->buffer)
-- m_dllAvUtil.av_free(m_ioContext->buffer);
-- m_dllAvUtil.av_free(m_ioContext);
-+ CLog::Log(LOGWARNING, "CDVDDemuxFFmpeg::Dispose - demuxer changed our byte context behind our back, possible memleak");
-+ m_ioContext = m_pFormatContext->pb;
- }
-- else
-- m_dllAvFormat.av_close_input_file(m_pFormatContext);
-+ m_dllAvFormat.avformat_close_input(&m_pFormatContext);
- }
- m_ioContext = NULL;
- m_pFormatContext = NULL;
-@@ -774,19 +758,12 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
- {
- stream->duration = duration;
- duration = m_dllAvUtil.av_rescale_rnd(stream->duration, (int64_t)stream->time_base.num * AV_TIME_BASE, stream->time_base.den, AV_ROUND_NEAR_INF);
-- if ((m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE && m_pFormatContext->file_size > 0)
-+ if ((m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE)
- || (m_pFormatContext->duration != (int64_t)AV_NOPTS_VALUE && duration > m_pFormatContext->duration))
- m_pFormatContext->duration = duration;
- }
- }
-
-- // check if stream seem to have grown since start
-- if(m_pFormatContext->file_size > 0 && m_pFormatContext->pb)
-- {
-- if(m_pFormatContext->pb->pos > m_pFormatContext->file_size)
-- m_pFormatContext->file_size = m_pFormatContext->pb->pos;
-- }
--
- pPacket->iStreamId = pkt.stream_index; // XXX just for now
- }
- m_dllAvCodec.av_free_packet(&pkt);
-@@ -924,19 +901,6 @@ int CDVDDemuxFFmpeg::GetStreamLength()
- if (!m_pFormatContext)
- return 0;
-
-- /* apperently ffmpeg messes up sometimes, so check for negative value too */
-- if (m_pFormatContext->duration == (int64_t)AV_NOPTS_VALUE || m_pFormatContext->duration < 0LL)
-- {
-- // no duration is available for us
-- // try to calculate it
-- int iLength = 0;
-- if (m_iCurrentPts != DVD_NOPTS_VALUE && m_pFormatContext->file_size > 0 && m_pFormatContext->pb && m_pFormatContext->pb->pos > 0)
-- {
-- iLength = (int)(((m_iCurrentPts * m_pFormatContext->file_size) / m_pFormatContext->pb->pos) / 1000) & 0xFFFFFFFF;
-- }
-- return iLength;
-- }
--
- return (int)(m_pFormatContext->duration / (AV_TIME_BASE / 1000));
- }
-
-@@ -971,6 +935,12 @@ static double SelectAspect(AVStream* st, bool* forced)
-
- void CDVDDemuxFFmpeg::AddStream(int iId)
- {
-+ if(iId >= MAX_STREAMS)
-+ {
-+ CLog::Log(LOGWARNING, "%s - streams id %d exeeds maximum supported", __FUNCTION__, iId);
-+ return;
-+ }
-+
- AVStream* pStream = m_pFormatContext->streams[iId];
- if (pStream)
- {
-@@ -988,8 +958,8 @@ void CDVDDemuxFFmpeg::AddStream(int iId)
- st->iBitRate = pStream->codec->bit_rate;
- st->iBitsPerSample = pStream->codec->bits_per_coded_sample;
-
-- if(m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0))
-- st->m_description = m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0)->value;
-+ if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0))
-+ st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value;
-
- break;
- }
-@@ -1078,8 +1048,8 @@ void CDVDDemuxFFmpeg::AddStream(int iId)
- if(pStream->codec)
- st->identifier = pStream->codec->sub_id;
-
-- if(m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0))
-- st->m_description = m_dllAvFormat.av_metadata_get(pStream->metadata, "title", NULL, 0)->value;
-+ if(m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0))
-+ st->m_description = m_dllAvUtil.av_dict_get(pStream->metadata, "title", NULL, 0)->value;
-
- break;
- }
-@@ -1090,7 +1060,7 @@ void CDVDDemuxFFmpeg::AddStream(int iId)
- {
- std::string fileName = "special://temp/fonts/";
- XFILE::CDirectory::Create(fileName);
-- AVMetadataTag *nameTag = m_dllAvFormat.av_metadata_get(pStream->metadata, "filename", NULL, 0);
-+ AVDictionaryEntry *nameTag = m_dllAvUtil.av_dict_get(pStream->metadata, "filename", NULL, 0);
- if (!nameTag) {
- CLog::Log(LOGERROR, "%s: TTF attachment has no name", __FUNCTION__);
- break;
-@@ -1139,7 +1109,7 @@ void CDVDDemuxFFmpeg::AddStream(int iId)
- // API added on: 2010-10-15
- // (Note that while the function was available earlier, the generic
- // metadata tags were not populated by default)
-- AVMetadataTag *langTag = m_dllAvFormat.av_metadata_get(pStream->metadata, "language", NULL, 0);
-+ AVDictionaryEntry *langTag = m_dllAvUtil.av_dict_get(pStream->metadata, "language", NULL, 0);
- if (langTag)
- strncpy(m_streams[iId]->language, langTag->value, 3);
- #else
-@@ -1249,7 +1219,7 @@ void CDVDDemuxFFmpeg::GetChapterName(std::string& strChapterName)
- // API added on: 2010-10-15
- // (Note that while the function was available earlier, the generic
- // metadata tags were not populated by default)
-- AVMetadataTag *titleTag = m_dllAvFormat.av_metadata_get(m_pFormatContext->chapters[chapterIdx-1]->metadata,
-+ AVDictionaryEntry *titleTag = m_dllAvUtil.av_dict_get(m_pFormatContext->chapters[chapterIdx-1]->metadata,
- "title", NULL, 0);
- if (titleTag)
- strChapterName = titleTag->value;
-diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
-index 018d9b3..84ea4b7 100644
---- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
-+++ b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.h
-@@ -128,7 +128,7 @@ protected:
- #define MAX_STREAMS 100
- CDemuxStream* m_streams[MAX_STREAMS]; // maximum number of streams that ffmpeg can handle
-
-- ByteIOContext* m_ioContext;
-+ AVIOContext* m_ioContext;
-
- DllAvFormat m_dllAvFormat;
- DllAvCodec m_dllAvCodec;
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-index e28faaf..eb51038 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-@@ -413,6 +413,7 @@ void CDVDPlayerVideo::Process()
- {
- if(m_pVideoCodec)
- m_pVideoCodec->Reset();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
- m_started = false;
- }
-@@ -420,6 +421,7 @@ void CDVDPlayerVideo::Process()
- {
- if(m_pVideoCodec)
- m_pVideoCodec->Reset();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
-
- m_pullupCorrection.Flush();
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch
deleted file mode 100644
index 68c31b264a..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.03-ffmpeg_crystalhd_implementation.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From 5c62df65cb2ef1c7dcebbf07bd6d180960ab6715 Mon Sep 17 00:00:00 2001
-From: theuni
-Date: Wed, 4 Apr 2012 14:53:51 -0400
-Subject: [PATCH] ffmpeg: disable ffmpeg's crystalhd implementation for now
-
----
- configure.in | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/configure.in b/configure.in
-index 0d80719..40e9fb5 100755
---- a/configure.in
-+++ b/configure.in
-@@ -2041,6 +2041,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
- --disable-ffmpeg \
- --disable-doc \
- --disable-decoder=mpeg_xvmc \
-+ --disable-crystalhd \
- --enable-postproc \
- --enable-gpl \
- --enable-protocol=http \
-@@ -2080,6 +2081,7 @@ XB_CONFIG_MODULE([lib/ffmpeg], [
- --disable-ffplay \
- --disable-ffserver \
- --disable-ffmpeg \
-+ --disable-crystalhd \
- --enable-shared \
- --disable-doc \
- --enable-postproc \
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.41-avfilter-depends-on-avformat.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.41-avfilter-depends-on-avformat.patch
deleted file mode 100644
index 04708b7219..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-901.41-avfilter-depends-on-avformat.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-From d1e06c28d3eb6cd689b8cbc5b96babe81707baa7 Mon Sep 17 00:00:00 2001
-From: Rainer Hochecker
-Date: Sun, 15 Apr 2012 14:00:22 +0200
-Subject: [PATCH] ffmpeg: avfilter depends on avformat
-
----
- lib/DllAvFilter.h | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/lib/DllAvFilter.h b/lib/DllAvFilter.h
-index 5c83654..6ae5d15 100644
---- a/lib/DllAvFilter.h
-+++ b/lib/DllAvFilter.h
-@@ -25,6 +25,7 @@
- #endif
- #include "DynamicDll.h"
- #include "DllAvCodec.h"
-+#include "DllAvFormat.h"
- #include "DllSwResample.h"
- #include "utils/log.h"
-
-@@ -203,6 +204,7 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
- /* dependencies of libavfilter */
- DllAvUtil m_dllAvUtil;
- DllSwResample m_dllSwResample;
-+ DllAvFormat m_dllAvFormat;
-
- public:
- int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
-@@ -251,6 +253,8 @@ class DllAvFilter : public DllDynamic, DllAvFilterInterface
- return false;
- if (!m_dllSwResample.Load())
- return false;
-+ if (!m_dllAvFormat.Load())
-+ return false;
- return DllDynamic::Load();
- }
- };
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.00-vdpau_reset_pvr_changes.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.00-vdpau_reset_pvr_changes.patch
deleted file mode 100644
index 2fdf1dbed4..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.00-vdpau_reset_pvr_changes.patch
+++ /dev/null
@@ -1,91 +0,0 @@
-diff -Naur xbmc-pvr-11.0.1/language/Dutch/strings.xml xbmc-pvr-11.0.1.patch/language/Dutch/strings.xml
---- xbmc-pvr-11.0.1/language/Dutch/strings.xml 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/language/Dutch/strings.xml 2012-05-14 14:13:28.656860932 +0200
-@@ -1542,7 +1542,6 @@
- Spline36
- Spline36 geoptimaliseerd
- Software menging
-- Auto - ION geoptimaliseerd
-
- Kwaliteitsverbetering video
-
-diff -Naur xbmc-pvr-11.0.1/language/English/strings.xml xbmc-pvr-11.0.1.patch/language/English/strings.xml
---- xbmc-pvr-11.0.1/language/English/strings.xml 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/language/English/strings.xml 2012-05-14 14:13:28.661861033 +0200
-@@ -1539,9 +1539,7 @@
- DXVA Best
- Spline36
- Spline36 optimized
--
- Software Blend
-- Auto - ION Optimized
-
- Post-processing
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-05-14 14:11:52.791931577 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-05-14 14:13:28.663861073 +0200
-@@ -531,8 +531,7 @@
- bool CVDPAU::Supports(EINTERLACEMETHOD method)
- {
- if(method == VS_INTERLACEMETHOD_VDPAU_BOB
-- || method == VS_INTERLACEMETHOD_AUTO
-- || method == VS_INTERLACEMETHOD_AUTO_ION)
-+ || method == VS_INTERLACEMETHOD_AUTO)
- return true;
-
- for(SInterlaceMapping* p = g_interlace_mapping; p->method != VS_INTERLACEMETHOD_NONE; p++)
-@@ -658,21 +657,8 @@
- }
- else
- {
-- if (method == VS_INTERLACEMETHOD_AUTO_ION)
-- {
-- if (vid_height <= 576)
-- {
-- VdpBool enabled[]={1,1,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else if (vid_height > 576)
-- {
-- VdpBool enabled[]={1,0,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- }
-- else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF)
-+ if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF)
- {
- VdpBool enabled[]={1,0,0};
- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-@@ -1399,16 +1385,14 @@
- if (mode == VS_DEINTERLACEMODE_FORCE
- || (mode == VS_DEINTERLACEMODE_AUTO && m_DVDVideoPics.front().iFlags & DVP_FLAG_INTERLACED))
- {
-- if((method == VS_INTERLACEMETHOD_AUTO_ION
-- || method == VS_INTERLACEMETHOD_VDPAU_BOB
-+ if((method == VS_INTERLACEMETHOD_VDPAU_BOB
- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
- || method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE ))
- {
-- if((method == VS_INTERLACEMETHOD_AUTO_ION && vid_height > 576)
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-+ if(method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
- || avctx->skip_frame == AVDISCARD_NONREF)
- m_mixerstep = 0;
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/dialogs/GUIDialogVideoSettings.cpp xbmc-pvr-11.0.1.patch/xbmc/video/dialogs/GUIDialogVideoSettings.cpp
---- xbmc-pvr-11.0.1/xbmc/video/dialogs/GUIDialogVideoSettings.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/dialogs/GUIDialogVideoSettings.cpp 2012-05-14 14:13:28.664861093 +0200
-@@ -113,7 +113,6 @@
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE , 16314));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BOB , 16320));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BEST , 16321));
-- entries.push_back(make_pair(VS_INTERLACEMETHOD_AUTO_ION , 16325));
-
- /* remove unsupported methods */
- for(vector >::iterator it = entries.begin(); it != entries.end();)
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch
deleted file mode 100644
index 98a4fa1a77..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.01-xvba_support_vdpau_rework-c633159.patch
+++ /dev/null
@@ -1,14563 +0,0 @@
-diff -Naur xbmc-pvr-11.0.1/configure.in xbmc-pvr-11.0.1.patch/configure.in
---- xbmc-pvr-11.0.1/configure.in 2012-05-14 14:11:49.081856910 +0200
-+++ xbmc-pvr-11.0.1.patch/configure.in 2012-05-14 14:15:12.045218673 +0200
-@@ -98,6 +98,8 @@
- vaapi_disabled="== VAAPI support manually disabled. =="
- crystalhd_not_found="== Could not find libcrystalhd. CrystalHD support disabled. =="
- crystalhd_disabled="== CrystalHD support manually disabled. =="
-+xvba_not_found="== Could not find amdxvba.h. XVBA support disabled. =="
-+xvba_disabled="== XVBA support manually disabled. =="
- vdadecoder_enabled="== VDADecoder support enabled. =="
- vdadecoder_disabled="== VDADecoder support manually disabled. =="
- vtbdecoder_enabled="== VTBDecoder support enabled. =="
-@@ -204,6 +206,12 @@
- [enable CrystalHD decoding (default is auto)])],
- [use_crystalhd=$enableval],
- [use_crystalhd=auto])
-+
-+AC_ARG_ENABLE([xvba],
-+ [AS_HELP_STRING([--enable-xvba],
-+ [enable XVBA decoding (default is auto)])],
-+ [use_xvba=$enableval],
-+ [use_xvba=auto])
-
- AC_ARG_ENABLE([vdadecoder],
- [AS_HELP_STRING([--enable-vdadecoder],
-@@ -1382,6 +1390,38 @@
- USE_CRYSTALHD=0
- fi
-
-+# XVBA
-+if test "x$use_xvba" != "xno"; then
-+ if test "$host_vendor" = "apple" ; then
-+ if test "x$use_xvba" = "xyes"; then
-+ AC_MSG_ERROR([XVBA not supported on this platform])
-+ else
-+ use_xvba="no"
-+ AC_MSG_NOTICE($xvba_disabled)
-+ fi
-+ USE_XVBA=0
-+ else
-+ initial_val=$use_xvba
-+ AC_CHECK_HEADER([amd/amdxvba.h],, use_xvba=no, [#include ])
-+
-+ if test "x$use_xvba" = "xno"; then
-+ if test "x$initial_val" = "xyes"; then
-+ AC_MSG_ERROR($xvba_not_found)
-+ else
-+ AC_MSG_RESULT($xvba_not_found)
-+ fi
-+ USE_XVBA=0
-+ else
-+ AC_DEFINE([HAVE_LIBXVBA], [1], [Define to 1 if you have the 'xvba' header (amdxvba.h)])
-+ USE_XVBA=1
-+ fi
-+ fi
-+else
-+ AC_MSG_NOTICE($xvba_disabled)
-+ USE_XVBA=0
-+fi
-+
-+
- # VDADecoder
- if test "x$use_vdadecoder" != "xno"; then
- if test "$host_vendor" = "apple" ; then
-@@ -1578,6 +1618,12 @@
- final_message="$final_message\n CrystalHD:\tNo"
- fi
-
-+if test "x$use_xvba" != "xno"; then
-+ final_message="$final_message\n XVBA:\t\tYes"
-+else
-+ final_message="$final_message\n XVBA:\t\tNo"
-+fi
-+
- if test "x$use_vdadecoder" != "xno"; then
- final_message="$final_message\n VDADecoder:\tYes"
- else
-@@ -1952,6 +1998,7 @@
- AC_SUBST(USE_VDPAU)
- AC_SUBST(USE_VAAPI)
- AC_SUBST(USE_CRYSTALHD)
-+AC_SUBST(USE_XVBA)
- AC_SUBST(USE_LIBSMBCLIENT)
- AC_SUBST(USE_LIBNFS)
- AC_SUBST(USE_LIBAFPCLIENT)
-@@ -2094,6 +2141,7 @@
- --enable-gpl \
- `if test "x$use_vdpau" != "xno"; then echo --enable-vdpau; else echo --disable-vdpau; fi` \
- `if test "x$use_vaapi" != "xno"; then echo --enable-vaapi; else echo --disable-vaapi; fi` \
-+ `if test "x$use_xvba" != "xno"; then echo --enable-xvba; else echo --disable-xvba; fi` \
- --enable-protocol=http \
- --enable-pthreads \
- --enable-runtime-cpudetect \
-diff -Naur xbmc-pvr-11.0.1/language/Dutch/strings.xml xbmc-pvr-11.0.1.patch/language/Dutch/strings.xml
---- xbmc-pvr-11.0.1/language/Dutch/strings.xml 2012-05-14 14:14:51.670808009 +0200
-+++ xbmc-pvr-11.0.1.patch/language/Dutch/strings.xml 2012-05-14 14:15:12.051218793 +0200
-@@ -1236,7 +1236,8 @@
- Hardwareversnelling inschakelen (OpenMax)
- Pixelshaders
- Hardware acceleratie toestaan (VideoToolbox)
--
-+ Vdpau OpenGL interop RGB inschakelen
-+ Vdpau OpenGL interop YUV inschakelen
- A/V-synchronisatiemethode
- Audiosignaal
- Videosignaal (Drop/Dupe audio)
-@@ -1542,6 +1543,7 @@
- Spline36
- Spline36 geoptimaliseerd
- Software menging
-+ VDPAU Bob
-
- Kwaliteitsverbetering video
-
-diff -Naur xbmc-pvr-11.0.1/language/English/strings.xml xbmc-pvr-11.0.1.patch/language/English/strings.xml
---- xbmc-pvr-11.0.1/language/English/strings.xml 2012-05-14 14:14:51.673808069 +0200
-+++ xbmc-pvr-11.0.1.patch/language/English/strings.xml 2012-05-14 14:15:12.053218833 +0200
-@@ -1234,6 +1234,9 @@
- Allow hardware acceleration (OpenMax)
- Pixel Shaders
- Allow hardware acceleration (VideoToolbox)
-+ Allow Vdpau OpenGL interop RGB
-+ Allow Vdpau OpenGL interop YUV
-+ Allow hardware acceleration (XVBA)
-
- A/V sync method
- Audio clock
-@@ -1540,6 +1543,8 @@
- Spline36
- Spline36 optimized
- Software Blend
-+ VDPAU Bob
-+ XVBA
-
- Post-processing
-
-diff -Naur xbmc-pvr-11.0.1/language/German/strings.xml xbmc-pvr-11.0.1.patch/language/German/strings.xml
---- xbmc-pvr-11.0.1/language/German/strings.xml 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/language/German/strings.xml 2012-05-14 14:15:12.059218956 +0200
-@@ -1268,6 +1268,8 @@
- Hardwarebeschleunigung erlauben (OpenMax)
- Pixel Shaders
- Hardwarebeschleunigung erlauben (VideoToolbox)
-+ Vdpau OpenGL interop RGB erlauben
-+ Vdpau OpenGL interop YUV erlauben
-
- A/V Sync Methode
- Audio Takt
-@@ -1567,6 +1569,7 @@
- Zeitlich (Hälfte)
- Zeitlich/Räumlich (Hälfte)
- DXVA
-+ VDPAU Bob
-
- Video Nachbearbeitung
- Deaktiviert
-diff -Naur xbmc-pvr-11.0.1/language/Swedish/strings.xml xbmc-pvr-11.0.1.patch/language/Swedish/strings.xml
---- xbmc-pvr-11.0.1/language/Swedish/strings.xml 2012-03-27 17:55:51.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/language/Swedish/strings.xml 2012-05-14 14:15:12.062219016 +0200
-@@ -1412,6 +1412,7 @@
- Spline36
- Spline36-optimerad
- Mjukvarublandning
-+ VDPAU Bob
- Efterbearbetning
- Visa insommningstimeout
- Byt till kanal
-diff -Naur xbmc-pvr-11.0.1/lib/UnrarXLib/extract.cpp xbmc-pvr-11.0.1.patch/lib/UnrarXLib/extract.cpp
---- xbmc-pvr-11.0.1/lib/UnrarXLib/extract.cpp 2012-03-27 17:55:39.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/UnrarXLib/extract.cpp 2012-05-14 14:15:12.095219681 +0200
-@@ -1,9 +1,5 @@
- #include "rar.hpp"
- #include "Util.h"
--#ifdef _LINUX
--#include "XSyncUtils.h"
--#include "XEventUtils.h"
--#endif
-
- // a cautious wrapper around strncpy
- char *strncpy_null_terminated(char *dest, const char *src, size_t n)
-diff -Naur xbmc-pvr-11.0.1/lib/UnrarXLib/unpack15.cpp xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack15.cpp
---- xbmc-pvr-11.0.1/lib/UnrarXLib/unpack15.cpp 2012-03-27 17:55:39.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack15.cpp 2012-05-14 14:15:12.095219681 +0200
-@@ -1,7 +1,3 @@
--#ifdef _LINUX
--#include "XSyncUtils.h"
--#endif
--
- #define STARTL1 2
- static unsigned int DecL1[]={0x8000,0xa000,0xc000,0xd000,0xe000,0xea00,
- 0xee00,0xf000,0xf200,0xf200,0xffff};
-diff -Naur xbmc-pvr-11.0.1/lib/UnrarXLib/unpack.cpp xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack.cpp
---- xbmc-pvr-11.0.1/lib/UnrarXLib/unpack.cpp 2012-03-27 17:55:39.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/lib/UnrarXLib/unpack.cpp 2012-05-14 14:15:12.096219701 +0200
-@@ -8,11 +8,6 @@
- #include "unpack20.cpp"
- #endif
-
--#ifdef _LINUX
--#include "XSyncUtils.h"
--#include "XEventUtils.h"
--#endif
--
- Unpack::Unpack(ComprDataIO *DataIO)
- {
- UnpIO=DataIO;
-diff -Naur xbmc-pvr-11.0.1/system/shaders/yuv2rgb_basic.glsl xbmc-pvr-11.0.1.patch/system/shaders/yuv2rgb_basic.glsl
---- xbmc-pvr-11.0.1/system/shaders/yuv2rgb_basic.glsl 2012-03-27 17:55:54.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/system/shaders/yuv2rgb_basic.glsl 2012-05-14 14:15:12.097219721 +0200
-@@ -70,6 +70,18 @@
- rgb.a = gl_Color.a;
- gl_FragColor = rgb;
-
-+#elif defined(XBMC_VDPAU_NV12)
-+
-+ vec4 yuv, rgb;
-+ yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r
-+ , texture2D(m_sampU, stretch(m_cordU)).r
-+ , texture2D(m_sampV, stretch(m_cordV)).g
-+ , 1.0 );
-+
-+ rgb = m_yuvmat * yuv;
-+ rgb.a = gl_Color.a;
-+ gl_FragColor = rgb;
-+
- #elif defined(XBMC_YUY2) || defined(XBMC_UYVY)
-
- #if(XBMC_texture_rectangle)
-diff -Naur xbmc-pvr-11.0.1/xbmc/Application.cpp xbmc-pvr-11.0.1.patch/xbmc/Application.cpp
---- xbmc-pvr-11.0.1/xbmc/Application.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/Application.cpp 2012-05-14 14:15:12.101219801 +0200
-@@ -391,8 +391,6 @@
- #endif
- m_currentStack = new CFileItemList;
-
-- m_frameCount = 0;
--
- m_bPresentFrame = false;
- m_bPlatformDirectories = true;
-
-@@ -2026,28 +2024,18 @@
-
- bool CApplication::WaitFrame(unsigned int timeout)
- {
-- bool done = false;
--
- // Wait for all other frames to be presented
-- CSingleLock lock(m_frameMutex);
-- //wait until event is set, but modify remaining time
-+ m_frameEvent.Reset();
-
-- TightConditionVariable > cv(m_frameCond, InversePredicate(m_frameCount));
-- cv.wait(lock,timeout);
-- done = m_frameCount == 0;
-+ if (!g_renderManager.HasFrame() && !m_frameEvent.WaitMSec(timeout))
-+ return false;
-
-- return done;
-+ return g_renderManager.HasFrame();
- }
-
- void CApplication::NewFrame()
- {
-- // We just posted another frame. Keep track and notify.
-- {
-- CSingleLock lock(m_frameMutex);
-- m_frameCount++;
-- }
--
-- m_frameCond.notifyAll();
-+ m_frameEvent.Set();
- }
-
- void CApplication::Render()
-@@ -2081,12 +2069,13 @@
- m_bPresentFrame = false;
- if (!extPlayerActive && g_graphicsContext.IsFullScreenVideo() && !IsPaused())
- {
-- CSingleLock lock(m_frameMutex);
--
-- TightConditionVariable cv(m_frameCond,m_frameCount);
-- cv.wait(lock,100);
-+ uint64_t timeout = CurrentHostCounter() + CurrentHostFrequency()/10;
-+ while (!g_renderManager.HasFrame() && CurrentHostCounter() < timeout)
-+ {
-+ m_frameEvent.WaitMSec(100);
-+ }
-+ m_bPresentFrame = g_renderManager.HasFrame();
-
-- m_bPresentFrame = m_frameCount > 0;
- decrement = m_bPresentFrame;
- hasRendered = true;
- }
-@@ -2169,18 +2158,14 @@
- m_lastFrameTime = XbmcThreads::SystemClockMillis();
-
- if (flip)
-+ {
- g_graphicsContext.Flip(dirtyRegions);
-+ g_renderManager.NotifyDisplayFlip();
-+ }
- CTimeUtils::UpdateFrameTime(flip);
-
- g_renderManager.UpdateResolution();
- g_renderManager.ManageCaptures();
--
-- {
-- CSingleLock lock(m_frameMutex);
-- if(m_frameCount > 0 && decrement)
-- m_frameCount--;
-- }
-- m_frameCond.notifyAll();
- }
-
- void CApplication::SetStandAlone(bool value)
-@@ -5399,12 +5384,6 @@
- // See if we're playing a video, and are in GUI mode
- if ( IsPlayingVideo() && g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO)
- {
-- // Reset frame count so that timing is FPS will be correct.
-- {
-- CSingleLock lock(m_frameMutex);
-- m_frameCount = 0;
-- }
--
- // then switch to fullscreen mode
- g_windowManager.ActivateWindow(WINDOW_FULLSCREEN_VIDEO);
- return true;
-@@ -5580,7 +5559,6 @@
-
- bool CApplication::IsPresentFrame()
- {
-- CSingleLock lock(m_frameMutex);
- bool ret = m_bPresentFrame;
-
- return ret;
-diff -Naur xbmc-pvr-11.0.1/xbmc/Application.h xbmc-pvr-11.0.1.patch/xbmc/Application.h
---- xbmc-pvr-11.0.1/xbmc/Application.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/Application.h 2012-05-14 14:15:12.102219821 +0200
-@@ -351,9 +351,7 @@
- bool m_bTestMode;
- bool m_bSystemScreenSaverEnable;
-
-- int m_frameCount;
-- CCriticalSection m_frameMutex;
-- XbmcThreads::ConditionVariable m_frameCond;
-+ CEvent m_frameEvent;
-
- void Mute();
- void UnMute();
-diff -Naur xbmc-pvr-11.0.1/xbmc/ApplicationMessenger.cpp xbmc-pvr-11.0.1.patch/xbmc/ApplicationMessenger.cpp
---- xbmc-pvr-11.0.1/xbmc/ApplicationMessenger.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/ApplicationMessenger.cpp 2012-05-14 14:15:12.106219903 +0200
-@@ -75,7 +75,7 @@
-
- using namespace std;
-
--CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay)
-+CDelayedMessage::CDelayedMessage(ThreadMessage& msg, unsigned int delay) : CThread("CDelayedMessage")
- {
- m_msg.dwMessage = msg.dwMessage;
- m_msg.dwParam1 = msg.dwParam1;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cdrip/CDDAReader.cpp xbmc-pvr-11.0.1.patch/xbmc/cdrip/CDDAReader.cpp
---- xbmc-pvr-11.0.1/xbmc/cdrip/CDDAReader.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cdrip/CDDAReader.cpp 2012-05-14 14:15:12.106219903 +0200
-@@ -29,7 +29,7 @@
-
- #define SECTOR_COUNT 52
-
--CCDDAReader::CCDDAReader()
-+CCDDAReader::CCDDAReader() : CThread("CCDDAReader")
- {
- m_sRipBuffer[0].pbtStream = NULL;
- m_sRipBuffer[1].pbtStream = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.cpp 2012-05-14 14:15:12.107219923 +0200
-@@ -240,15 +240,6 @@
- #endif
- }
-
--extern "C" BOOL WINAPI dllGetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime)
--{
-- // since the xbox has only one process, we just take the current thread
-- HANDLE h = GetCurrentThread();
-- BOOL res = GetThreadTimes(h, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime);
--
-- return res;
--}
--
- extern "C" int WINAPI dllDuplicateHandle(HANDLE hSourceProcessHandle, // handle to source process
- HANDLE hSourceHandle, // handle to duplicate
- HANDLE hTargetProcessHandle, // handle to target process
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.h xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.h
---- xbmc-pvr-11.0.1/xbmc/cores/DllLoader/exports/emu_kernel32.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/DllLoader/exports/emu_kernel32.h 2012-05-14 14:15:12.108219943 +0200
-@@ -686,7 +686,6 @@
-
- extern "C" HGLOBAL WINAPI dllLoadResource(HMODULE module, HRSRC res);
- extern "C" HRSRC WINAPI dllFindResourceA(HMODULE module, LPCTSTR name, LPCTSTR type);
--extern "C" BOOL WINAPI dllGetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
- extern "C" int WINAPI dllGetLocaleInfoA(LCID Locale, LCTYPE LCType, LPTSTR lpLCData, int cchData);
- extern "C" UINT WINAPI dllGetConsoleCP();
- extern "C" UINT WINAPI dllGetConsoleOutputCP();
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/DummyVideoPlayer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/DummyVideoPlayer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/DummyVideoPlayer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/DummyVideoPlayer.cpp 2012-05-14 14:15:12.109219963 +0200
-@@ -33,7 +33,7 @@
-
- CDummyVideoPlayer::CDummyVideoPlayer(IPlayerCallback& callback)
- : IPlayer(callback),
-- CThread()
-+ CThread("CDummyVideoPlayer")
- {
- m_paused = false;
- m_clock = 0;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/CrystalHD.cpp 2012-05-14 14:15:12.111220003 +0200
-@@ -325,7 +325,7 @@
- #pragma mark -
- #endif
- CMPCOutputThread::CMPCOutputThread(void *device, DllLibCrystalHD *dll, bool has_bcm70015) :
-- CThread(),
-+ CThread("CMPCOutputThread"),
- m_dll(dll),
- m_device(device),
- m_has_bcm70015(has_bcm70015),
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-05-14 14:11:52.781931376 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp 2012-05-14 14:32:47.792343580 +0200
-@@ -56,6 +56,9 @@
- #ifdef HAVE_LIBVA
- #include "VAAPI.h"
- #endif
-+#ifdef HAVE_LIBXVBA
-+#include "XVBA.h"
-+#endif
-
- using namespace boost;
-
-@@ -71,14 +74,14 @@
- while(*cur != PIX_FMT_NONE)
- {
- #ifdef HAVE_LIBVDPAU
-- if(CVDPAU::IsVDPAUFormat(*cur) && g_guiSettings.GetBool("videoplayer.usevdpau"))
-+ if(VDPAU::CDecoder::IsVDPAUFormat(*cur) && g_guiSettings.GetBool("videoplayer.usevdpau"))
- {
- if(ctx->GetHardware())
- return *cur;
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
-- CVDPAU* vdp = new CVDPAU();
-- if(vdp->Open(avctx, *cur))
-+ VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
-+ if(vdp->Open(avctx, *cur, ctx->m_uSurfacesCount))
- {
- ctx->SetHardware(vdp);
- return *cur;
-@@ -100,6 +103,19 @@
- dec->Release();
- }
- #endif
-+#ifdef HAVE_LIBXVBA
-+ if(*cur == PIX_FMT_XVBA_VLD && g_guiSettings.GetBool("videoplayer.usexvba"))
-+ {
-+ XVBA::CDecoder* dec = new XVBA::CDecoder();
-+ if(dec->Open(avctx, *cur))
-+ {
-+ ctx->SetHardware(dec);
-+ return *cur;
-+ }
-+ else
-+ dec->Release();
-+ }
-+#endif
- #ifdef HAVE_LIBVA
- // mpeg4 vaapi decoding is disabled
- if(*cur == PIX_FMT_VAAPI_VLD && g_guiSettings.GetBool("videoplayer.usevaapi")
-@@ -141,6 +157,7 @@
- m_iLastKeyframe = 0;
- m_dts = DVD_NOPTS_VALUE;
- m_started = false;
-+ m_decoderPts = DVD_NOPTS_VALUE;
- }
-
- CDVDVideoCodecFFmpeg::~CDVDVideoCodecFFmpeg()
-@@ -198,14 +215,26 @@
- continue;
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Creating VDPAU(%ix%i, %d)",hints.width, hints.height, hints.codec);
-- CVDPAU* vdp = new CVDPAU();
-+ VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->codec_id = hints.codec;
- m_pCodecContext->width = hints.width;
- m_pCodecContext->height = hints.height;
- m_pCodecContext->coded_width = hints.width;
- m_pCodecContext->coded_height = hints.height;
-- if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE))
-+
-+ // check number of surfaces used in renderer
-+ unsigned int surfaces = 0;
-+ for(CDVDCodecOptions::iterator it = options.begin(); it != options.end(); it++)
-+ {
-+ if (it->m_name == "surfaces")
-+ {
-+ surfaces = std::atoi(it->m_value.c_str());
-+ break;
-+ }
-+ }
-+
-+ if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE, surfaces))
- {
- m_pHardware = vdp;
- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
-@@ -333,6 +362,14 @@
- {
- if( m_pCodecContext )
- {
-+ if (bDrop && m_pHardware && m_pHardware->CanSkipDeint())
-+ {
-+ m_requestSkipDeint = true;
-+ bDrop = false;
-+ }
-+ else
-+ m_requestSkipDeint = false;
-+
- // i don't know exactly how high this should be set
- // couldn't find any good docs on it. think it varies
- // from codec to codec on what it does
-@@ -515,6 +552,7 @@
- void CDVDVideoCodecFFmpeg::Reset()
- {
- m_started = false;
-+ m_decoderPts = DVD_NOPTS_VALUE;
- m_iLastKeyframe = m_pCodecContext->has_b_frames;
- m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext);
-
-@@ -608,6 +646,22 @@
- else
- pDvdVideoPicture->pts = DVD_NOPTS_VALUE;
-
-+ if (pDvdVideoPicture->pts != DVD_NOPTS_VALUE)
-+ m_decoderPts = pDvdVideoPicture->pts;
-+ else
-+ m_decoderPts = m_dts;
-+
-+ if (m_requestSkipDeint)
-+ {
-+ pDvdVideoPicture->iFlags |= DVP_FLAG_DROPDEINT;
-+ m_skippedDeint = 1;
-+ }
-+ else
-+ m_skippedDeint = 0;
-+
-+ m_requestSkipDeint = false;
-+ pDvdVideoPicture->iFlags |= m_codecControlState;
-+
- if(!m_started)
- pDvdVideoPicture->iFlags |= DVP_FLAG_DROPPED;
-
-@@ -827,3 +881,14 @@
- else
- return 0;
- }
-+
-+void CDVDVideoCodecFFmpeg::SetSpeed(int speed)
-+{
-+ if (m_pHardware)
-+ m_pHardware->SetSpeed(speed);
-+}
-+
-+void CDVDVideoCodecFFmpeg::SetCodecControl(int state)
-+{
-+ m_codecControlState = state;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-05-14 14:11:52.782931396 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h 2012-05-14 14:30:28.105682654 +0200
-@@ -29,7 +29,6 @@
- #include "DllSwScale.h"
- #include "DllAvFilter.h"
-
--class CVDPAU;
- class CCriticalSection;
-
- class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
-@@ -45,6 +44,8 @@
- virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture) = 0;
- virtual int Check (AVCodecContext* avctx) = 0;
- virtual void Reset () {}
-+ virtual bool CanSkipDeint() {return false; }
-+ virtual void SetSpeed(int speed) {}
- virtual const std::string Name() = 0;
- virtual CCriticalSection* Section() { return NULL; }
- };
-@@ -61,6 +62,9 @@
- virtual unsigned int SetFilters(unsigned int filters);
- virtual const char* GetName() { return m_name.c_str(); }; // m_name is never changed after open
- virtual unsigned GetConvergeCount();
-+ virtual bool GetPts(double &pts, int &skippedDeint, int &interlaced) {pts=m_decoderPts; skippedDeint=m_skippedDeint; if (m_pFrame) interlaced = m_pFrame->interlaced_frame; return true;}
-+ virtual void SetSpeed(int speed);
-+ virtual void SetCodecControl(int state);
-
- bool IsHardwareAllowed() { return !m_bSoftware; }
- IHardwareDecoder * GetHardware() { return m_pHardware; };
-@@ -118,5 +122,9 @@
- int m_iLastKeyframe;
- double m_dts;
- bool m_started;
-+ double m_decoderPts, m_decoderInterval;
-+ int m_skippedDeint;
-+ bool m_requestSkipDeint;
-+ int m_codecControlState;
- std::vector m_formats;
- };
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h 2012-05-14 14:15:12.117220123 +0200
-@@ -34,7 +34,8 @@
-
- namespace DXVA { class CSurfaceContext; }
- namespace VAAPI { struct CHolder; }
--class CVDPAU;
-+namespace VDPAU { class CVdpauRenderPicture; }
-+namespace XVBA { class CXvbaRenderPicture; }
- class COpenMax;
- class COpenMaxVideo;
- struct OpenMaxVideoBuffer;
-@@ -59,11 +60,14 @@
- DXVA::CSurfaceContext* context;
- };
- struct {
-- CVDPAU* vdpau;
-+ VDPAU::CVdpauRenderPicture* vdpau;
- };
- struct {
- VAAPI::CHolder* vaapi;
- };
-+ struct {
-+ XVBA::CXvbaRenderPicture* xvba;
-+ };
-
- struct {
- COpenMax *openMax;
-@@ -102,6 +106,7 @@
- enum EFormat {
- FMT_YUV420P = 0,
- FMT_VDPAU,
-+ FMT_VDPAU_420,
- FMT_NV12,
- FMT_UYVY,
- FMT_YUY2,
-@@ -109,6 +114,7 @@
- FMT_VAAPI,
- FMT_OMXEGL,
- FMT_CVBREF,
-+ FMT_XVBA,
- } format;
- };
-
-@@ -125,6 +131,10 @@
-
- #define DVP_FLAG_NOSKIP 0x00000010 // indicate this picture should never be dropped
- #define DVP_FLAG_DROPPED 0x00000020 // indicate that this picture has been dropped in decoder stage, will have no data
-+#define DVP_FLAG_DROPDEINT 0x00000040 // indicate that this picture was requested to have been dropped in deint stage
-+
-+#define DVP_FLAG_SKIP_PROC 0x00000100
-+#define DVP_FLAG_DRAIN 0x00000200
-
- // DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2!
-
-@@ -143,6 +153,10 @@
- #define VC_PICTURE 0x00000004 // the decoder got a picture, call Decode(NULL, 0) again to parse the rest of the data
- #define VC_USERDATA 0x00000008 // the decoder found some userdata, call Decode(NULL, 0) again to parse the rest of the data
- #define VC_FLUSHED 0x00000010 // the decoder lost it's state, we need to restart decoding again
-+#define VC_DROPPED 0x00000020 // needed to identify if a picture was dropped
-+#define VC_HURRY 0x00000040
-+#define VC_SKIPPROC 0x00000080
-+
- class CDVDVideoCodec
- {
- public:
-@@ -207,7 +221,6 @@
- */
- virtual void SetDropState(bool bDrop) = 0;
-
--
- enum EFilterFlags {
- FILTER_NONE = 0x0,
- FILTER_DEINTERLACE_YADIF = 0x1, /* use first deinterlace mode */
-@@ -237,4 +250,16 @@
- {
- return 0;
- }
-+
-+ virtual bool GetPts(double &pts, int &skippedDeint, int &interlaced)
-+ {
-+ return false;
-+ }
-+
-+ virtual void SetSpeed(int speed)
-+ {
-+ return;
-+ }
-+
-+ virtual void SetCodecControl(int state) {}
- };
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/Makefile.in 2012-05-14 14:15:12.118220144 +0200
-@@ -17,6 +17,10 @@
- DVDVideoCodecCrystalHD.cpp \
-
- endif
-+ifeq (@USE_XVBA@,1)
-+SRCS+= XVBA.cpp \
-+
-+endif
- ifeq (@USE_VDA@,1)
- SRCS+= DVDVideoCodecVDA.cpp \
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-05-14 14:14:51.682808251 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp 2012-05-14 14:15:12.128220346 +0200
-@@ -1,5 +1,5 @@
- /*
-- * Copyright (C) 2005-2009 Team XBMC
-+ * Copyright (C) 2005-2011 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
-@@ -33,11 +33,16 @@
- #include "settings/AdvancedSettings.h"
- #include "Application.h"
- #include "utils/MathUtils.h"
-+#include "utils/TimeUtils.h"
- #include "DVDCodecs/DVDCodecUtils.h"
-+#include "cores/VideoRenderers/RenderFlags.h"
-+
-+using namespace VDPAU;
-+#define NUM_RENDER_PICS 9
-
- #define ARSIZE(x) (sizeof(x) / sizeof((x)[0]))
-
--CVDPAU::Desc decoder_profiles[] = {
-+CDecoder::Desc decoder_profiles[] = {
- {"MPEG1", VDP_DECODER_PROFILE_MPEG1},
- {"MPEG2_SIMPLE", VDP_DECODER_PROFILE_MPEG2_SIMPLE},
- {"MPEG2_MAIN", VDP_DECODER_PROFILE_MPEG2_MAIN},
-@@ -51,14 +56,16 @@
- {"MPEG4_PART2_ASP", VDP_DECODER_PROFILE_MPEG4_PART2_ASP},
- #endif
- };
--const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(CVDPAU::Desc);
-+const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(CDecoder::Desc);
-
--static float studioCSC[3][4] =
--{
-- { 1.0f, 0.0f, 1.57480000f,-0.78740000f},
-- { 1.0f,-0.18737736f,-0.46813736f, 0.32775736f},
-- { 1.0f, 1.85556000f, 0.0f,-0.92780000f}
--};
-+//static float studioCSC[3][4] =
-+//{
-+// { 1.0f, 0.0f, 1.57480000f,-0.78740000f},
-+// { 1.0f,-0.18737736f,-0.46813736f, 0.32775736f},
-+// { 1.0f, 1.85556000f, 0.0f,-0.92780000f}
-+//};
-+static float studioCSCKCoeffs601[3] = {0.299, 0.587, 0.114}; //BT601 {Kr, Kg, Kb}
-+static float studioCSCKCoeffs709[3] = {0.2126, 0.7152, 0.0722}; //BT709 {Kr, Kg, Kb}
-
- static struct SInterlaceMapping
- {
-@@ -69,59 +76,32 @@
- , {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF , VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL}
- , {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL , VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL}
- , {VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF, VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL}
--, {VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE , VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE}
-+, {VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE , VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE}
- , {VS_INTERLACEMETHOD_NONE , (VdpVideoMixerFeature)-1}
- };
-
- //since libvdpau 0.4, vdp_device_create_x11() installs a callback on the Display*,
- //if we unload libvdpau with dlclose(), we segfault on XCloseDisplay,
- //so we just keep a static handle to libvdpau around
--void* CVDPAU::dl_handle;
--
--CVDPAU::CVDPAU()
--{
-- glXBindTexImageEXT = NULL;
-- glXReleaseTexImageEXT = NULL;
-- vdp_device = VDP_INVALID_HANDLE;
-- surfaceNum = presentSurfaceNum = 0;
-- picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
-- vdpauConfigured = false;
-- m_DisplayState = VDPAU_OPEN;
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-- m_mixerstep = 0;
-+void* CDecoder::dl_handle;
-
-- m_glPixmap = 0;
-- m_Pixmap = 0;
-- if (!glXBindTexImageEXT)
-- glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT");
-- if (!glXReleaseTexImageEXT)
-- glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT");
--
-- totalAvailableOutputSurfaces = 0;
-- outputSurface = presentSurface = VDP_INVALID_HANDLE;
-- vdp_flip_target = VDP_INVALID_HANDLE;
-- vdp_flip_queue = VDP_INVALID_HANDLE;
-- vid_width = vid_height = OutWidth = OutHeight = 0;
-- memset(&outRect, 0, sizeof(VdpRect));
-- memset(&outRectVid, 0, sizeof(VdpRect));
--
-- tmpBrightness = 0;
-- tmpContrast = 0;
-- tmpDeintMode = 0;
-- tmpDeintGUI = 0;
-- tmpDeint = 0;
-- max_references = 0;
--
-- for (int i = 0; i < NUM_OUTPUT_SURFACES; i++)
-- outputSurfaces[i] = VDP_INVALID_HANDLE;
-+//-----------------------------------------------------------------------------
-+// CVDPAU
-+//-----------------------------------------------------------------------------
-
-- videoMixer = VDP_INVALID_HANDLE;
-- m_BlackBar = NULL;
-+CDecoder::CDecoder() : m_vdpauOutput(&m_inMsgEvent)
-+{
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
-+ m_vdpauConfig.videoSurfaces = &m_videoSurfaces;
-+ m_vdpauConfig.videoSurfaceSec = &m_videoSurfaceSec;
-
-- upScale = g_advancedSettings.m_videoVDPAUScaling;
-+ m_picAge.b_age = m_picAge.ip_age[0] = m_picAge.ip_age[1] = 256*256*256*64;
-+ m_vdpauConfigured = false;
-+ m_DisplayState = VDPAU_OPEN;
-+ m_speed = DVD_PLAYSPEED_NORMAL;
- }
-
--bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
-+bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
- {
- if(avctx->coded_width == 0
- || avctx->coded_height == 0)
-@@ -129,6 +109,8 @@
- CLog::Log(LOGWARNING,"(VDPAU) no width/height available, can't init");
- return false;
- }
-+ m_vdpauConfig.numRenderBuffers = surfaces;
-+ m_decoderThread = CThread::GetCurrentThreadId();
-
- if (!dl_handle)
- {
-@@ -140,8 +122,6 @@
- error = "dlerror() returned NULL";
-
- CLog::Log(LOGNOTICE,"(VDPAU) Unable to get handle to libvdpau: %s", error);
-- //g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, "VDPAU", error, 10000);
--
- return false;
- }
- }
-@@ -150,8 +130,9 @@
- return false;
-
- InitVDPAUProcs();
-+ m_presentPicture = 0;
-
-- if (vdp_device != VDP_INVALID_HANDLE)
-+ if (m_vdpauConfig.vdpDevice != VDP_INVALID_HANDLE)
- {
- SpewHardwareAvailable();
-
-@@ -169,25 +150,23 @@
-
- /* attempt to create a decoder with this width/height, some sizes are not supported by hw */
- VdpStatus vdp_st;
-- vdp_st = vdp_decoder_create(vdp_device, profile, avctx->coded_width, avctx->coded_height, 5, &decoder);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice, profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder);
-
- if(vdp_st != VDP_STATUS_OK)
- {
-- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", vdp_get_error_string(vdp_st), vdp_st);
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st);
- FiniVDPAUProcs();
- return false;
- }
-
-- vdp_decoder_destroy(decoder);
-+ m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
- CheckStatus(vdp_st, __LINE__);
- }
-
-- InitCSCMatrix(avctx->coded_height);
--
- /* finally setup ffmpeg */
-- avctx->get_buffer = CVDPAU::FFGetBuffer;
-- avctx->release_buffer = CVDPAU::FFReleaseBuffer;
-- avctx->draw_horiz_band = CVDPAU::FFDrawSlice;
-+ avctx->get_buffer = CDecoder::FFGetBuffer;
-+ avctx->release_buffer = CDecoder::FFReleaseBuffer;
-+ avctx->draw_horiz_band = CDecoder::FFDrawSlice;
- avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
-
- g_Windowing.Register(this);
-@@ -196,17 +175,20 @@
- return false;
- }
-
--CVDPAU::~CVDPAU()
-+CDecoder::~CDecoder()
- {
- Close();
- }
-
--void CVDPAU::Close()
-+void CDecoder::Close()
- {
- CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__);
-
-+ CSingleLock lock(m_DecoderSection);
-+
- FiniVDPAUOutput();
- FiniVDPAUProcs();
-+ m_vdpauOutput.Dispose();
-
- while (!m_videoSurfaces.empty())
- {
-@@ -222,188 +204,118 @@
- m_dllAvUtil.Unload();
- }
-
--bool CVDPAU::MakePixmapGL()
-+long CDecoder::Release()
- {
-- int num=0;
-- int fbConfigIndex = 0;
--
-- int doubleVisAttributes[] = {
-- GLX_RENDER_TYPE, GLX_RGBA_BIT,
-- GLX_RED_SIZE, 8,
-- GLX_GREEN_SIZE, 8,
-- GLX_BLUE_SIZE, 8,
-- GLX_ALPHA_SIZE, 8,
-- GLX_DEPTH_SIZE, 8,
-- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
-- GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
-- GLX_DOUBLEBUFFER, True,
-- GLX_Y_INVERTED_EXT, True,
-- GLX_X_RENDERABLE, True,
-- None
-- };
--
-- int pixmapAttribs[] = {
-- GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
-- GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
-- None
-- };
-+ // check if we should do some pre-cleanup here
-+ // a second decoder might need resources
-+ if (m_vdpauConfigured == true)
-+ {
-+ CSingleLock lock(m_DecoderSection);
-+ CLog::Log(LOGNOTICE,"CVDPAU::Release pre-cleanup");
-+
-+ Message *reply;
-+ if (m_vdpauOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::PRECLEANUP,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - pre-cleanup returned error", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
-+ }
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - pre-cleanup timed out", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
-+ }
-
-- GLXFBConfig *fbConfigs;
-- fbConfigs = glXChooseFBConfig(m_Display, DefaultScreen(m_Display), doubleVisAttributes, &num);
-- if (fbConfigs==NULL)
-- {
-- CLog::Log(LOGERROR, "GLX Error: MakePixmap: No compatible framebuffers found");
-- return false;
-+ for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
-+ {
-+ vdpau_render_state *render = m_videoSurfaces[i];
-+ if (render->surface != VDP_INVALID_HANDLE && !(render->state & FF_VDPAU_STATE_USED_FOR_RENDER))
-+ {
-+ m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface);
-+ render->surface = VDP_INVALID_HANDLE;
-+ }
-+ }
- }
-- CLog::Log(LOGDEBUG, "Found %d fbconfigs.", num);
-- fbConfigIndex = 0;
-- CLog::Log(LOGDEBUG, "Using fbconfig index %d.", fbConfigIndex);
-+ IHardwareDecoder::Release();
-+}
-
-- m_glPixmap = glXCreatePixmap(m_Display, fbConfigs[fbConfigIndex], m_Pixmap, pixmapAttribs);
-+long CDecoder::ReleasePicReference()
-+{
-+ return IHardwareDecoder::Release();
-+}
-
-- if (!m_glPixmap)
-+void CDecoder::SetWidthHeight(int width, int height)
-+{
-+ int vdpauMaxHeight = g_advancedSettings.m_videoVDPAUmaxHeight;
-+ if (vdpauMaxHeight > 0 && height > vdpauMaxHeight)
- {
-- CLog::Log(LOGINFO, "GLX Error: Could not create Pixmap");
-- XFree(fbConfigs);
-- return false;
-+ width = MathUtils::round_int((double)width * vdpauMaxHeight / height);
-+ height = vdpauMaxHeight;
- }
-- XFree(fbConfigs);
-
-- return true;
--}
-+ m_vdpauConfig.upscale = g_advancedSettings.m_videoVDPAUScaling;
-
--bool CVDPAU::MakePixmap(int width, int height)
--{
- //pick the smallest dimensions, so we downscale with vdpau and upscale with opengl when appropriate
- //this requires the least amount of gpu memory bandwidth
-- if (g_graphicsContext.GetWidth() < width || g_graphicsContext.GetHeight() < height || upScale)
-+ if (g_graphicsContext.GetWidth() < width || g_graphicsContext.GetHeight() < height || m_vdpauConfig.upscale >= 0)
- {
- //scale width to desktop size if the aspect ratio is the same or bigger than the desktop
- if ((double)height * g_graphicsContext.GetWidth() / width <= (double)g_graphicsContext.GetHeight())
- {
-- OutWidth = g_graphicsContext.GetWidth();
-- OutHeight = MathUtils::round_int((double)height * g_graphicsContext.GetWidth() / width);
-+ m_vdpauConfig.outWidth = g_graphicsContext.GetWidth();
-+ m_vdpauConfig.outHeight = MathUtils::round_int((double)height * g_graphicsContext.GetWidth() / width);
- }
- else //scale height to the desktop size if the aspect ratio is smaller than the desktop
- {
-- OutHeight = g_graphicsContext.GetHeight();
-- OutWidth = MathUtils::round_int((double)width * g_graphicsContext.GetHeight() / height);
-+ m_vdpauConfig.outHeight = g_graphicsContext.GetHeight();
-+ m_vdpauConfig.outWidth = MathUtils::round_int((double)width * g_graphicsContext.GetHeight() / height);
- }
- }
- else
- { //let opengl scale
-- OutWidth = width;
-- OutHeight = height;
-- }
--
-- CLog::Log(LOGNOTICE,"Creating %ix%i pixmap", OutWidth, OutHeight);
--
-- // Get our window attribs.
-- XWindowAttributes wndattribs;
-- XGetWindowAttributes(m_Display, DefaultRootWindow(m_Display), &wndattribs); // returns a status but I don't know what success is
--
-- m_Pixmap = XCreatePixmap(m_Display,
-- DefaultRootWindow(m_Display),
-- OutWidth,
-- OutHeight,
-- wndattribs.depth);
-- if (!m_Pixmap)
-- {
-- CLog::Log(LOGERROR, "GLX Error: MakePixmap: Unable to create XPixmap");
-- return false;
-- }
--
-- XGCValues values = {};
-- GC xgc;
-- values.foreground = BlackPixel (m_Display, DefaultScreen (m_Display));
-- xgc = XCreateGC(m_Display, m_Pixmap, GCForeground, &values);
-- XFillRectangle(m_Display, m_Pixmap, xgc, 0, 0, OutWidth, OutHeight);
-- XFreeGC(m_Display, xgc);
--
-- if(!MakePixmapGL())
-- return false;
--
-- return true;
--}
--
--void CVDPAU::BindPixmap()
--{
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return;
-- }
--
-- if (m_glPixmap)
-- {
-- if(presentSurface != VDP_INVALID_HANDLE)
-- {
-- VdpPresentationQueueStatus status;
-- VdpTime time;
-- VdpStatus vdp_st;
-- vdp_st = vdp_presentation_queue_query_surface_status(
-- vdp_flip_queue, presentSurface, &status, &time);
-- CheckStatus(vdp_st, __LINE__);
-- while(status != VDP_PRESENTATION_QUEUE_STATUS_VISIBLE && vdp_st == VDP_STATUS_OK)
-- {
-- Sleep(1);
-- vdp_st = vdp_presentation_queue_query_surface_status(
-- vdp_flip_queue, presentSurface, &status, &time);
-- CheckStatus(vdp_st, __LINE__);
-- }
-- }
--
-- glXBindTexImageEXT(m_Display, m_glPixmap, GLX_FRONT_LEFT_EXT, NULL);
-- }
-- else CLog::Log(LOGERROR,"(VDPAU) BindPixmap called without valid pixmap");
--}
--
--void CVDPAU::ReleasePixmap()
--{
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return;
-- }
--
-- if (m_glPixmap)
-- {
-- glXReleaseTexImageEXT(m_Display, m_glPixmap, GLX_FRONT_LEFT_EXT);
-+ m_vdpauConfig.outWidth = width;
-+ m_vdpauConfig.outHeight = height;
- }
-- else CLog::Log(LOGERROR,"(VDPAU) ReleasePixmap called without valid pixmap");
-+ CLog::Log(LOGDEBUG, "CVDPAU::SetWidthHeight Setting OutWidth: %i OutHeight: %i vdpauMaxHeight: %i", m_vdpauConfig.outWidth, m_vdpauConfig.outHeight, vdpauMaxHeight);
- }
-
--void CVDPAU::OnLostDevice()
-+void CDecoder::OnLostDevice()
- {
- CLog::Log(LOGNOTICE,"CVDPAU::OnLostDevice event");
-
-- CExclusiveLock lock(m_DecoderSection);
-+ CSingleLock lock(m_DecoderSection);
- FiniVDPAUOutput();
- FiniVDPAUProcs();
-
- m_DisplayState = VDPAU_LOST;
-+ lock.Leave();
- m_DisplayEvent.Reset();
- }
-
--void CVDPAU::OnResetDevice()
-+void CDecoder::OnResetDevice()
- {
- CLog::Log(LOGNOTICE,"CVDPAU::OnResetDevice event");
-
-- CExclusiveLock lock(m_DisplaySection);
-+ CSingleLock lock(m_DecoderSection);
- if (m_DisplayState == VDPAU_LOST)
- {
- m_DisplayState = VDPAU_RESET;
-+ lock.Leave();
- m_DisplayEvent.Set();
- }
- }
-
--int CVDPAU::Check(AVCodecContext* avctx)
-+int CDecoder::Check(AVCodecContext* avctx)
- {
- EDisplayState state;
-
-- { CSharedLock lock(m_DisplaySection);
-+ { CSingleLock lock(m_DecoderSection);
- state = m_DisplayState;
- }
-
-@@ -417,16 +329,13 @@
- }
- else
- {
-- CSharedLock lock(m_DisplaySection);
-+ CSingleLock lock(m_DecoderSection);
- state = m_DisplayState;
- }
- }
- if (state == VDPAU_RESET || state == VDPAU_ERROR)
- {
-- CLog::Log(LOGNOTICE,"Attempting recovery");
--
-- CSingleLock gLock(g_graphicsContext);
-- CExclusiveLock lock(m_DecoderSection);
-+ CSingleLock lock(m_DecoderSection);
-
- FiniVDPAUOutput();
- FiniVDPAUProcs();
-@@ -441,7 +350,7 @@
- return 0;
- }
-
--bool CVDPAU::IsVDPAUFormat(PixelFormat format)
-+bool CDecoder::IsVDPAUFormat(PixelFormat format)
- {
- if ((format >= PIX_FMT_VDPAU_H264) && (format <= PIX_FMT_VDPAU_VC1)) return true;
- #if (defined PIX_FMT_VDPAU_MPEG4_IN_AVUTIL)
-@@ -450,90 +359,28 @@
- else return false;
- }
-
--void CVDPAU::CheckFeatures()
--{
-- if (videoMixer == VDP_INVALID_HANDLE)
-- {
-- CLog::Log(LOGNOTICE, " (VDPAU) Creating the video mixer");
-- // Creation of VideoMixer.
-- VdpVideoMixerParameter parameters[] = {
-- VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
-- VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
-- VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE
-- };
--
-- void const * parameter_values[] = {
-- &surface_width,
-- &surface_height,
-- &vdp_chroma_type
-- };
--
-- tmpBrightness = 0;
-- tmpContrast = 0;
-- tmpNoiseReduction = 0;
-- tmpSharpness = 0;
--
-- VdpStatus vdp_st = VDP_STATUS_ERROR;
-- vdp_st = vdp_video_mixer_create(vdp_device,
-- m_feature_count,
-- m_features,
-- ARSIZE(parameters),
-- parameters,
-- parameter_values,
-- &videoMixer);
-- CheckStatus(vdp_st, __LINE__);
--
-- SetHWUpscaling();
-- }
--
-- if (tmpBrightness != g_settings.m_currentVideoSettings.m_Brightness ||
-- tmpContrast != g_settings.m_currentVideoSettings.m_Contrast)
-- {
-- SetColor();
-- tmpBrightness = g_settings.m_currentVideoSettings.m_Brightness;
-- tmpContrast = g_settings.m_currentVideoSettings.m_Contrast;
-- }
-- if (tmpNoiseReduction != g_settings.m_currentVideoSettings.m_NoiseReduction)
-- {
-- tmpNoiseReduction = g_settings.m_currentVideoSettings.m_NoiseReduction;
-- SetNoiseReduction();
-- }
-- if (tmpSharpness != g_settings.m_currentVideoSettings.m_Sharpness)
-- {
-- tmpSharpness = g_settings.m_currentVideoSettings.m_Sharpness;
-- SetSharpness();
-- }
-- if ( tmpDeintMode != g_settings.m_currentVideoSettings.m_DeinterlaceMode ||
-- tmpDeintGUI != g_settings.m_currentVideoSettings.m_InterlaceMethod ||
-- (tmpDeintGUI == VS_INTERLACEMETHOD_AUTO && tmpDeint != AutoInterlaceMethod()))
-- {
-- tmpDeintMode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-- tmpDeintGUI = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-- if (tmpDeintGUI == VS_INTERLACEMETHOD_AUTO)
-- tmpDeint = AutoInterlaceMethod();
-- else
-- tmpDeint = tmpDeintGUI;
--
-- SetDeinterlacing();
-- }
--}
--
--bool CVDPAU::Supports(VdpVideoMixerFeature feature)
-+bool CDecoder::Supports(VdpVideoMixerFeature feature)
- {
-- for(int i = 0; i < m_feature_count; i++)
-+ for(int i = 0; i < m_vdpauConfig.featureCount; i++)
- {
-- if(m_features[i] == feature)
-+ if(m_vdpauConfig.vdpFeatures[i] == feature)
- return true;
- }
- return false;
- }
-
--bool CVDPAU::Supports(EINTERLACEMETHOD method)
-+bool CDecoder::Supports(EINTERLACEMETHOD method)
- {
- if(method == VS_INTERLACEMETHOD_VDPAU_BOB
- || method == VS_INTERLACEMETHOD_AUTO)
- return true;
-
-+ if (g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv"))
-+ {
-+ if (method == VS_INTERLACEMETHOD_RENDER_BOB)
-+ return true;
-+ }
-+
- for(SInterlaceMapping* p = g_interlace_mapping; p->method != VS_INTERLACEMETHOD_NONE; p++)
- {
- if(p->method == method)
-@@ -542,149 +389,12 @@
- return false;
- }
-
--EINTERLACEMETHOD CVDPAU::AutoInterlaceMethod()
--{
-- return VS_INTERLACEMETHOD_VDPAU_TEMPORAL;
--}
--
--void CVDPAU::SetColor()
--{
-- VdpStatus vdp_st;
--
-- if (tmpBrightness != g_settings.m_currentVideoSettings.m_Brightness)
-- m_Procamp.brightness = (float)((g_settings.m_currentVideoSettings.m_Brightness)-50) / 100;
-- if (tmpContrast != g_settings.m_currentVideoSettings.m_Contrast)
-- m_Procamp.contrast = (float)((g_settings.m_currentVideoSettings.m_Contrast)+50) / 100;
--
-- if(vid_height >= 600 || vid_width > 1024)
-- vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_709, &m_CSCMatrix);
-- else
-- vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_601, &m_CSCMatrix);
--
-- VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX };
-- if (g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
-- {
-- void const * pm_CSCMatix[] = { &studioCSC };
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-- }
-- else
-- {
-- void const * pm_CSCMatix[] = { &m_CSCMatrix };
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-- }
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::SetNoiseReduction()
--{
-- if(!Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
-- return;
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION };
-- VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL };
-- VdpStatus vdp_st;
--
-- if (!g_settings.m_currentVideoSettings.m_NoiseReduction)
-- {
-- VdpBool enabled[]= {0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- return;
-- }
-- VdpBool enabled[]={1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- void* nr[] = { &g_settings.m_currentVideoSettings.m_NoiseReduction };
-- CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",g_settings.m_currentVideoSettings.m_NoiseReduction);
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, nr);
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::SetSharpness()
--{
-- if(!Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
-- return;
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS };
-- VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL };
-- VdpStatus vdp_st;
--
-- if (!g_settings.m_currentVideoSettings.m_Sharpness)
-- {
-- VdpBool enabled[]={0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- return;
-- }
-- VdpBool enabled[]={1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
-- void* sh[] = { &g_settings.m_currentVideoSettings.m_Sharpness };
-- CLog::Log(LOGNOTICE,"Setting Sharpness to %f",g_settings.m_currentVideoSettings.m_Sharpness);
-- vdp_st = vdp_video_mixer_set_attribute_values(videoMixer, ARSIZE(attributes), attributes, sh);
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::SetHWUpscaling()
--{
--#ifdef VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1
-- if(!Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1) || !upScale)
-- return;
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
-- VdpStatus vdp_st;
-- VdpBool enabled[]={1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- CheckStatus(vdp_st, __LINE__);
--#endif
--}
--
--void CVDPAU::SetDeinterlacing()
-+EINTERLACEMETHOD CDecoder::AutoInterlaceMethod()
- {
-- VdpStatus vdp_st;
-- EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-- EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-- if (method == VS_INTERLACEMETHOD_AUTO)
-- method = AutoInterlaceMethod();
--
-- VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
-- VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
-- VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE };
-- if (mode == VS_DEINTERLACEMODE_OFF)
-- {
-- VdpBool enabled[]={0,0,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else
-- {
-- if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF)
-- {
-- VdpBool enabled[]={1,0,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF)
-- {
-- VdpBool enabled[]={1,1,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else if (method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE)
-- {
-- VdpBool enabled[]={1,0,1};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- else
-- {
-- VdpBool enabled[]={0,0,0};
-- vdp_st = vdp_video_mixer_set_feature_enables(videoMixer, ARSIZE(feature), feature, enabled);
-- }
-- }
--
-- CheckStatus(vdp_st, __LINE__);
-+ return VS_INTERLACEMETHOD_RENDER_BOB;
- }
-
--void CVDPAU::InitVDPAUProcs()
-+void CDecoder::InitVDPAUProcs()
- {
- char* error;
-
-@@ -694,151 +404,115 @@
- if (error)
- {
- CLog::Log(LOGERROR,"(VDPAU) - %s in %s",error,__FUNCTION__);
-- vdp_device = VDP_INVALID_HANDLE;
--
-- //g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, "VDPAU", error, 10000);
--
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
- return;
- }
-
- if (dl_vdp_device_create_x11)
- {
-- CSingleLock lock(g_graphicsContext);
-- m_Display = g_Windowing.GetDisplay();
-+ m_Display = XOpenDisplay(NULL);
- }
-
- int mScreen = DefaultScreen(m_Display);
- VdpStatus vdp_st;
-
- // Create Device
-- // tested on 64bit Ubuntu 11.10 and it deadlocked without this
-- XLockDisplay(m_Display);
- vdp_st = dl_vdp_device_create_x11(m_Display, //x_display,
- mScreen, //x_screen,
-- &vdp_device,
-- &vdp_get_proc_address);
-- XUnlockDisplay(m_Display);
-+ &m_vdpauConfig.vdpDevice,
-+ &m_vdpauConfig.vdpProcs.vdp_get_proc_address);
-
-- CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",vdp_device,vdp_st);
-+ CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpauConfig.vdpDevice,vdp_st);
- if (vdp_st != VDP_STATUS_OK)
- {
- CLog::Log(LOGERROR,"(VDPAU) unable to init VDPAU - vdp_st = 0x%x. Falling back.",vdp_st);
-- vdp_device = VDP_INVALID_HANDLE;
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
- return;
- }
-
-- if (vdp_st != VDP_STATUS_OK)
-- {
-- CLog::Log(LOGERROR,"(VDPAU) - Unable to create X11 device in %s",__FUNCTION__);
-- vdp_device = VDP_INVALID_HANDLE;
-- return;
-- }
- #define VDP_PROC(id, proc) \
- do { \
-- vdp_st = vdp_get_proc_address(vdp_device, id, (void**)&proc); \
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_get_proc_address(m_vdpauConfig.vdpDevice, id, (void**)&proc); \
- CheckStatus(vdp_st, __LINE__); \
- } while(0);
-
-- VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , vdp_get_error_string);
-- VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , vdp_device_destroy);
-- VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , vdp_generate_csc_matrix);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , vdp_video_surface_create);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , vdp_video_surface_destroy);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , vdp_video_surface_put_bits_y_cb_cr);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , vdp_video_surface_get_bits_y_cb_cr);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , vdp_output_surface_put_bits_y_cb_cr);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , vdp_output_surface_put_bits_native);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , vdp_output_surface_create);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , vdp_output_surface_destroy);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , vdp_output_surface_get_bits_native);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, vdp_output_surface_render_output_surface);
-- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , vdp_output_surface_put_bits_indexed);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , vdp_video_mixer_create);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , vdp_video_mixer_set_feature_enables);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , vdp_video_mixer_destroy);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , vdp_video_mixer_render);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , vdp_video_mixer_set_attribute_values);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , vdp_video_mixer_query_parameter_support);
-- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , vdp_video_mixer_query_feature_support);
-- VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , vdp_decoder_create);
-- VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , vdp_decoder_destroy);
-- VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , vdp_decoder_render);
-- VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , vdp_decoder_query_caps);
-- VDP_PROC(VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER , vdp_preemption_callback_register);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , vdp_presentation_queue_target_destroy);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , vdp_presentation_queue_create);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , vdp_presentation_queue_destroy);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , vdp_presentation_queue_display);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, vdp_presentation_queue_block_until_surface_idle);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , vdp_presentation_queue_target_create_x11);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , vdp_presentation_queue_query_surface_status);
-- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , vdp_presentation_queue_get_time);
--
-+ VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , m_vdpauConfig.vdpProcs.vdp_get_error_string);
-+ VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , m_vdpauConfig.vdpProcs.vdp_device_destroy);
-+ VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , m_vdpauConfig.vdpProcs.vdp_generate_csc_matrix);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_video_surface_create);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_surface_destroy);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_put_bits_y_cb_cr);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_video_surface_get_bits_y_cb_cr);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_y_cb_cr);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_native);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , m_vdpauConfig.vdpProcs.vdp_output_surface_create);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , m_vdpauConfig.vdpProcs.vdp_output_surface_destroy);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , m_vdpauConfig.vdpProcs.vdp_output_surface_get_bits_native);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, m_vdpauConfig.vdpProcs.vdp_output_surface_render_output_surface);
-+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , m_vdpauConfig.vdpProcs.vdp_output_surface_put_bits_indexed);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , m_vdpauConfig.vdpProcs.vdp_video_mixer_create);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_feature_enables);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , m_vdpauConfig.vdpProcs.vdp_video_mixer_destroy);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , m_vdpauConfig.vdpProcs.vdp_video_mixer_render);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , m_vdpauConfig.vdpProcs.vdp_video_mixer_set_attribute_values);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_parameter_support);
-+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , m_vdpauConfig.vdpProcs.vdp_video_mixer_query_feature_support);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , m_vdpauConfig.vdpProcs.vdp_decoder_create);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpauConfig.vdpProcs.vdp_decoder_destroy);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpauConfig.vdpProcs.vdp_decoder_render);
-+ VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpauConfig.vdpProcs.vdp_decoder_query_caps);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_destroy);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , m_vdpauConfig.vdpProcs.vdp_presentation_queue_create);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_destroy);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , m_vdpauConfig.vdpProcs.vdp_presentation_queue_display);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, m_vdpauConfig.vdpProcs.vdp_presentation_queue_block_until_surface_idle);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , m_vdpauConfig.vdpProcs.vdp_presentation_queue_target_create_x11);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , m_vdpauConfig.vdpProcs.vdp_presentation_queue_query_surface_status);
-+ VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , m_vdpauConfig.vdpProcs.vdp_presentation_queue_get_time);
-+
- #undef VDP_PROC
-
- // set all vdpau resources to invalid
-- vdp_flip_target = VDP_INVALID_HANDLE;
-- vdp_flip_queue = VDP_INVALID_HANDLE;
-- videoMixer = VDP_INVALID_HANDLE;
-- totalAvailableOutputSurfaces = 0;
-- presentSurface = VDP_INVALID_HANDLE;
-- outputSurface = VDP_INVALID_HANDLE;
-- for (int i = 0; i < NUM_OUTPUT_SURFACES; i++)
-- outputSurfaces[i] = VDP_INVALID_HANDLE;
--
-- m_vdpauOutputMethod = OUTPUT_NONE;
--
-- CExclusiveLock lock(m_DisplaySection);
- m_DisplayState = VDPAU_OPEN;
-- vdpauConfigured = false;
-+ m_vdpauConfigured = false;
- }
-
--void CVDPAU::FiniVDPAUProcs()
-+void CDecoder::FiniVDPAUProcs()
- {
-- if (vdp_device == VDP_INVALID_HANDLE) return;
-+ if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE) return;
-
- VdpStatus vdp_st;
-- vdp_st = vdp_device_destroy(vdp_device);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_device_destroy(m_vdpauConfig.vdpDevice);
- CheckStatus(vdp_st, __LINE__);
-- vdp_device = VDP_INVALID_HANDLE;
-- vdpauConfigured = false;
-+ m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
- }
-
--void CVDPAU::InitCSCMatrix(int Height)
-+void CDecoder::FiniVDPAUOutput()
- {
-+ if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE || !m_vdpauConfigured) return;
-+
-+ CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__);
-+
-+ // uninit output
-+ m_vdpauOutput.Dispose();
-+ m_vdpauConfigured = false;
-+
- VdpStatus vdp_st;
-- m_Procamp.struct_version = VDP_PROCAMP_VERSION;
-- m_Procamp.brightness = 0.0;
-- m_Procamp.contrast = 1.0;
-- m_Procamp.saturation = 1.0;
-- m_Procamp.hue = 0;
-- vdp_st = vdp_generate_csc_matrix(&m_Procamp,
-- (Height < 720)? VDP_COLOR_STANDARD_ITUR_BT_601 : VDP_COLOR_STANDARD_ITUR_BT_709,
-- &m_CSCMatrix);
-- CheckStatus(vdp_st, __LINE__);
--}
--
--void CVDPAU::FiniVDPAUOutput()
--{
-- FiniOutputMethod();
--
-- if (vdp_device == VDP_INVALID_HANDLE || !vdpauConfigured) return;
-
-- CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__);
--
-- VdpStatus vdp_st;
--
-- vdp_st = vdp_decoder_destroy(decoder);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
- if (CheckStatus(vdp_st, __LINE__))
- return;
-- decoder = VDP_INVALID_HANDLE;
-+ m_vdpauConfig.vdpDecoder = VDP_INVALID_HANDLE;
-
-- for (unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
-+ CSingleLock lock(m_videoSurfaceSec);
-+ CLog::Log(LOGDEBUG, "CVDPAU::FiniVDPAUOutput destroying %d video surfaces", (int)m_videoSurfaces.size());
-+
-+ for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
- {
- vdpau_render_state *render = m_videoSurfaces[i];
- if (render->surface != VDP_INVALID_HANDLE)
- {
-- vdp_st = vdp_video_surface_destroy(render->surface);
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(render->surface);
- render->surface = VDP_INVALID_HANDLE;
- }
- if (CheckStatus(vdp_st, __LINE__))
-@@ -846,8 +520,7 @@
- }
- }
-
--
--void CVDPAU::ReadFormatOf( PixelFormat fmt
-+void CDecoder::ReadFormatOf( PixelFormat fmt
- , VdpDecoderProfile &vdp_decoder_profile
- , VdpChromaType &vdp_chroma_type)
- {
-@@ -885,170 +558,78 @@
- }
- }
-
--
--bool CVDPAU::ConfigVDPAU(AVCodecContext* avctx, int ref_frames)
-+bool CDecoder::ConfigVDPAU(AVCodecContext* avctx, int ref_frames)
- {
- FiniVDPAUOutput();
-
- VdpStatus vdp_st;
- VdpDecoderProfile vdp_decoder_profile;
-- vid_width = avctx->width;
-- vid_height = avctx->height;
-- surface_width = avctx->coded_width;
-- surface_height = avctx->coded_height;
--
-- past[1] = past[0] = current = future = NULL;
-- CLog::Log(LOGNOTICE, " (VDPAU) screenWidth:%i vidWidth:%i surfaceWidth:%i",OutWidth,vid_width,surface_width);
-- CLog::Log(LOGNOTICE, " (VDPAU) screenHeight:%i vidHeight:%i surfaceHeight:%i",OutHeight,vid_height,surface_height);
-- ReadFormatOf(avctx->pix_fmt, vdp_decoder_profile, vdp_chroma_type);
-+
-+ m_vdpauConfig.vidWidth = avctx->width;
-+ m_vdpauConfig.vidHeight = avctx->height;
-+ m_vdpauConfig.surfaceWidth = avctx->coded_width;
-+ m_vdpauConfig.surfaceHeight = avctx->coded_height;
-+
-+ SetWidthHeight(avctx->width,avctx->height);
-+
-+ CLog::Log(LOGNOTICE, " (VDPAU) screenWidth:%i vidWidth:%i surfaceWidth:%i",m_vdpauConfig.outWidth,m_vdpauConfig.vidWidth,m_vdpauConfig.surfaceWidth);
-+ CLog::Log(LOGNOTICE, " (VDPAU) screenHeight:%i vidHeight:%i surfaceHeight:%i",m_vdpauConfig.outHeight,m_vdpauConfig.vidHeight,m_vdpauConfig.surfaceHeight);
-+
-+ ReadFormatOf(avctx->pix_fmt, vdp_decoder_profile, m_vdpauConfig.vdpChromaType);
-
- if(avctx->pix_fmt == PIX_FMT_VDPAU_H264)
- {
-- max_references = ref_frames;
-- if (max_references > 16) max_references = 16;
-- if (max_references < 5) max_references = 5;
-+ m_vdpauConfig.maxReferences = ref_frames;
-+ if (m_vdpauConfig.maxReferences > 16) m_vdpauConfig.maxReferences = 16;
-+ if (m_vdpauConfig.maxReferences < 5) m_vdpauConfig.maxReferences = 5;
- }
- else
-- max_references = 2;
-+ m_vdpauConfig.maxReferences = 2;
-
-- vdp_st = vdp_decoder_create(vdp_device,
-+ vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice,
- vdp_decoder_profile,
-- surface_width,
-- surface_height,
-- max_references,
-- &decoder);
-- if (CheckStatus(vdp_st, __LINE__))
-- return false;
--
-- m_vdpauOutputMethod = OUTPUT_NONE;
--
-- vdpauConfigured = true;
-- return true;
--}
--
--bool CVDPAU::ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame)
--{
-- VdpStatus vdp_st;
--
-- if (m_vdpauOutputMethod == OUTPUT_PIXMAP)
-- return true;
--
-- FiniOutputMethod();
--
-- MakePixmap(avctx->width,avctx->height);
--
-- vdp_st = vdp_presentation_queue_target_create_x11(vdp_device,
-- m_Pixmap, //x_window,
-- &vdp_flip_target);
-- if (CheckStatus(vdp_st, __LINE__))
-- return false;
--
-- vdp_st = vdp_presentation_queue_create(vdp_device,
-- vdp_flip_target,
-- &vdp_flip_queue);
-+ m_vdpauConfig.surfaceWidth,
-+ m_vdpauConfig.surfaceHeight,
-+ m_vdpauConfig.maxReferences,
-+ &m_vdpauConfig.vdpDecoder);
- if (CheckStatus(vdp_st, __LINE__))
- return false;
-
-- totalAvailableOutputSurfaces = 0;
--
-- int tmpMaxOutputSurfaces = NUM_OUTPUT_SURFACES;
-- if (vid_width == FULLHD_WIDTH)
-- tmpMaxOutputSurfaces = NUM_OUTPUT_SURFACES_FOR_FULLHD;
--
-- // Creation of outputSurfaces
-- for (int i = 0; i < NUM_OUTPUT_SURFACES && i < tmpMaxOutputSurfaces; i++)
-- {
-- vdp_st = vdp_output_surface_create(vdp_device,
-- VDP_RGBA_FORMAT_B8G8R8A8,
-- OutWidth,
-- OutHeight,
-- &outputSurfaces[i]);
-- if (CheckStatus(vdp_st, __LINE__))
-+ // initialize output
-+ CSingleLock lock(g_graphicsContext);
-+ m_vdpauConfig.stats = &m_bufferStats;
-+ m_vdpauConfig.vdpau = this;
-+ m_bufferStats.Reset();
-+ m_vdpauOutput.Start();
-+ Message *reply;
-+ if (m_vdpauOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::INIT,
-+ &reply,
-+ 2000,
-+ &m_vdpauConfig,
-+ sizeof(m_vdpauConfig)))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - vdpau output returned error", __FUNCTION__);
-+ m_vdpauOutput.Dispose();
- return false;
-- totalAvailableOutputSurfaces++;
-- }
-- CLog::Log(LOGNOTICE, " (VDPAU) Total Output Surfaces Available: %i of a max (tmp: %i const: %i)",
-- totalAvailableOutputSurfaces,
-- tmpMaxOutputSurfaces,
-- NUM_OUTPUT_SURFACES);
--
-- // create 3 pitches of black lines needed for clipping top
-- // and bottom lines when de-interlacing
-- m_BlackBar = new uint32_t[3*OutWidth];
-- memset(m_BlackBar, 0, 3*OutWidth*sizeof(uint32_t));
--
-- surfaceNum = presentSurfaceNum = 0;
-- outputSurface = presentSurface = VDP_INVALID_HANDLE;
-- videoMixer = VDP_INVALID_HANDLE;
--
-- m_vdpauOutputMethod = OUTPUT_PIXMAP;
--
-- return true;
--}
--
--bool CVDPAU::FiniOutputMethod()
--{
-- VdpStatus vdp_st;
--
-- if (vdp_flip_queue != VDP_INVALID_HANDLE)
-- {
-- vdp_st = vdp_presentation_queue_destroy(vdp_flip_queue);
-- vdp_flip_queue = VDP_INVALID_HANDLE;
-- CheckStatus(vdp_st, __LINE__);
-- }
--
-- if (vdp_flip_target != VDP_INVALID_HANDLE)
-- {
-- vdp_st = vdp_presentation_queue_target_destroy(vdp_flip_target);
-- vdp_flip_target = VDP_INVALID_HANDLE;
-- CheckStatus(vdp_st, __LINE__);
-- }
--
-- if (m_glPixmap)
-- {
-- CLog::Log(LOGDEBUG, "GLX: Destroying glPixmap");
-- glXDestroyPixmap(m_Display, m_glPixmap);
-- m_glPixmap = None;
-- }
--
-- if (m_Pixmap)
-- {
-- CLog::Log(LOGDEBUG, "GLX: Destroying XPixmap");
-- XFreePixmap(m_Display, m_Pixmap);
-- m_Pixmap = None;
-- }
--
-- outputSurface = presentSurface = VDP_INVALID_HANDLE;
--
-- for (int i = 0; i < totalAvailableOutputSurfaces; i++)
-- {
-- if (outputSurfaces[i] == VDP_INVALID_HANDLE)
-- continue;
-- vdp_st = vdp_output_surface_destroy(outputSurfaces[i]);
-- outputSurfaces[i] = VDP_INVALID_HANDLE;
-- CheckStatus(vdp_st, __LINE__);
-- }
--
-- if (videoMixer != VDP_INVALID_HANDLE)
-- {
-- vdp_st = vdp_video_mixer_destroy(videoMixer);
-- videoMixer = VDP_INVALID_HANDLE;
-- if (CheckStatus(vdp_st, __LINE__));
-+ }
- }
--
-- if (m_BlackBar)
-+ else
- {
-- delete [] m_BlackBar;
-- m_BlackBar = NULL;
-+ CLog::Log(LOGERROR, "VDPAU::%s - failed to init output", __FUNCTION__);
-+ m_vdpauOutput.Dispose();
-+ return false;
- }
-
-- while (!m_DVDVideoPics.empty())
-- m_DVDVideoPics.pop();
--
-+ m_inMsgEvent.Reset();
-+ m_vdpauConfigured = true;
- return true;
- }
-
--void CVDPAU::SpewHardwareAvailable() //Copyright (c) 2008 Wladimir J. van der Laan -- VDPInfo
-+void CDecoder::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo
- {
- VdpStatus rv;
- CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:");
-@@ -1058,7 +639,7 @@
- {
- VdpBool is_supported = false;
- uint32_t max_level, max_macroblocks, max_width, max_height;
-- rv = vdp_decoder_query_caps(vdp_device, decoder_profiles[x].id,
-+ rv = m_vdpauConfig.vdpProcs.vdp_decoder_query_caps(m_vdpauConfig.vdpDevice, decoder_profiles[x].id,
- &is_supported, &max_level, &max_macroblocks, &max_width, &max_height);
- if(rv == VDP_STATUS_OK && is_supported)
- {
-@@ -1067,13 +648,13 @@
- }
- }
- CLog::Log(LOGNOTICE,"------------------------------------");
-- m_feature_count = 0;
-+ m_vdpauConfig.featureCount = 0;
- #define CHECK_SUPPORT(feature) \
- do { \
- VdpBool supported; \
-- if(vdp_video_mixer_query_feature_support(vdp_device, feature, &supported) == VDP_STATUS_OK && supported) { \
-+ if(m_vdpauConfig.vdpProcs.vdp_video_mixer_query_feature_support(m_vdpauConfig.vdpDevice, feature, &supported) == VDP_STATUS_OK && supported) { \
- CLog::Log(LOGNOTICE, "Mixer feature: "#feature); \
-- m_features[m_feature_count++] = feature; \
-+ m_vdpauConfig.vdpFeatures[m_vdpauConfig.featureCount++] = feature; \
- } \
- } while(false)
-
-@@ -1097,7 +678,7 @@
-
- }
-
--bool CVDPAU::IsSurfaceValid(vdpau_render_state *render)
-+bool CDecoder::IsSurfaceValid(vdpau_render_state *render)
- {
- // find render state in queue
- bool found(false);
-@@ -1124,34 +705,34 @@
- return true;
- }
-
--int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
-+int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
- {
- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-- CVDPAU* vdp = (CVDPAU*)ctx->GetHardware();
-- struct pictureAge* pA = &vdp->picAge;
-+ CDecoder* vdp = (CDecoder*)ctx->GetHardware();
-+ struct PictureAge* pA = &vdp->m_picAge;
-
- // while we are waiting to recover we can't do anything
-- CSharedLock lock(vdp->m_DecoderSection);
-+ CSingleLock lock(vdp->m_DecoderSection);
-
-- { CSharedLock dLock(vdp->m_DisplaySection);
-- if(vdp->m_DisplayState != VDPAU_OPEN)
-- {
-- CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - returning due to awaiting recovery");
-- return -1;
-- }
-+ if(vdp->m_DisplayState != VDPAU_OPEN)
-+ {
-+ CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - returning due to awaiting recovery");
-+ return -1;
- }
-
- vdpau_render_state * render = NULL;
-
- // find unused surface
-- for(unsigned int i = 0; i < vdp->m_videoSurfaces.size(); i++)
-- {
-- if(!(vdp->m_videoSurfaces[i]->state & (FF_VDPAU_STATE_USED_FOR_REFERENCE | FF_VDPAU_STATE_USED_FOR_RENDER)))
-+ { CSingleLock lock(vdp->m_videoSurfaceSec);
-+ for(unsigned int i = 0; i < vdp->m_videoSurfaces.size(); i++)
- {
-- render = vdp->m_videoSurfaces[i];
-- render->state = 0;
-- break;
-+ if(!(vdp->m_videoSurfaces[i]->state & (FF_VDPAU_STATE_USED_FOR_REFERENCE | FF_VDPAU_STATE_USED_FOR_RENDER)))
-+ {
-+ render = vdp->m_videoSurfaces[i];
-+ render->state = 0;
-+ break;
-+ }
- }
- }
-
-@@ -1160,21 +741,22 @@
- {
- // create a new surface
- VdpDecoderProfile profile;
-- ReadFormatOf(avctx->pix_fmt, profile, vdp->vdp_chroma_type);
-+ ReadFormatOf(avctx->pix_fmt, profile, vdp->m_vdpauConfig.vdpChromaType);
- render = (vdpau_render_state*)calloc(sizeof(vdpau_render_state), 1);
- if (render == NULL)
- {
- CLog::Log(LOGWARNING, "CVDPAU::FFGetBuffer - calloc failed");
- return -1;
- }
-+ CSingleLock lock(vdp->m_videoSurfaceSec);
- render->surface = VDP_INVALID_HANDLE;
- vdp->m_videoSurfaces.push_back(render);
- }
-
- if (render->surface == VDP_INVALID_HANDLE)
- {
-- vdp_st = vdp->vdp_video_surface_create(vdp->vdp_device,
-- vdp->vdp_chroma_type,
-+ vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_video_surface_create(vdp->m_vdpauConfig.vdpDevice,
-+ vdp->m_vdpauConfig.vdpChromaType,
- avctx->coded_width,
- avctx->coded_height,
- &render->surface);
-@@ -1214,15 +796,16 @@
- return 0;
- }
-
--void CVDPAU::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic)
-+void CDecoder::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic)
- {
- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-- CVDPAU* vdp = (CVDPAU*)ctx->GetHardware();
-+ CDecoder* vdp = (CDecoder*)ctx->GetHardware();
-+
- vdpau_render_state * render;
- unsigned int i;
-
-- CSharedLock lock(vdp->m_DecoderSection);
-+ CSingleLock lock(vdp->m_DecoderSection);
-
- render=(vdpau_render_state*)pic->data[0];
- if(!render)
-@@ -1231,6 +814,8 @@
- return;
- }
-
-+ CSingleLock vLock(vdp->m_videoSurfaceSec);
-+ render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE;
- for(i=0; i<4; i++)
- pic->data[i]= NULL;
-
-@@ -1245,21 +830,18 @@
- }
-
-
--void CVDPAU::FFDrawSlice(struct AVCodecContext *s,
-+void CDecoder::FFDrawSlice(struct AVCodecContext *s,
- const AVFrame *src, int offset[4],
- int y, int type, int height)
- {
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)s->opaque;
-- CVDPAU* vdp = (CVDPAU*)ctx->GetHardware();
-+ CDecoder* vdp = (CDecoder*)ctx->GetHardware();
-
- // while we are waiting to recover we can't do anything
-- CSharedLock lock(vdp->m_DecoderSection);
--
-- { CSharedLock dLock(vdp->m_DisplaySection);
-- if(vdp->m_DisplayState != VDPAU_OPEN)
-- return;
-- }
-+ CSingleLock lock(vdp->m_DecoderSection);
-
-+ if(vdp->m_DisplayState != VDPAU_OPEN)
-+ return;
-
- if(src->linesize[0] || src->linesize[1] || src->linesize[2]
- || offset[0] || offset[1] || offset[2])
-@@ -1289,59 +871,41 @@
- if(s->pix_fmt == PIX_FMT_VDPAU_H264)
- max_refs = render->info.h264.num_ref_frames;
-
-- if(vdp->decoder == VDP_INVALID_HANDLE
-- || vdp->vdpauConfigured == false
-- || vdp->max_references < max_refs)
-+ if(vdp->m_vdpauConfig.vdpDecoder == VDP_INVALID_HANDLE
-+ || vdp->m_vdpauConfigured == false
-+ || vdp->m_vdpauConfig.maxReferences < max_refs)
- {
- if(!vdp->ConfigVDPAU(s, max_refs))
- return;
- }
-
-- vdp_st = vdp->vdp_decoder_render(vdp->decoder,
-+ uint64_t startTime = CurrentHostCounter();
-+ uint16_t decoded, processed, rend;
-+ vdp->m_bufferStats.Get(decoded, processed, rend);
-+ vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder,
- render->surface,
- (VdpPictureInfo const *)&(render->info),
- render->bitstream_buffers_used,
- render->bitstream_buffers);
- vdp->CheckStatus(vdp_st, __LINE__);
-+ uint64_t diff = CurrentHostCounter() - startTime;
-+ if (diff*1000/CurrentHostFrequency() > 30)
-+ CLog::Log(LOGWARNING,"CVDPAU::DrawSlice - VdpDecoderRender long decoding: %d ms, dec: %d, proc: %d, rend: %d", (int)((diff*1000)/CurrentHostFrequency()), decoded, processed, rend);
-+
- }
-
--int CVDPAU::Decode(AVCodecContext *avctx, AVFrame *pFrame)
--{
-- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
-- VdpStatus vdp_st;
-- VdpTime time;
-
-+int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame, bool bSoftDrain, bool bHardDrain)
-+{
- int result = Check(avctx);
- if (result)
- return result;
-
-- CSharedLock lock(m_DecoderSection);
-+ CSingleLock lock(m_DecoderSection);
-
-- if (!vdpauConfigured)
-+ if (!m_vdpauConfigured)
- return VC_ERROR;
-
-- // configure vdpau output
-- if (!ConfigOutputMethod(avctx, pFrame))
-- return VC_FLUSHED;
--
-- outputSurface = outputSurfaces[surfaceNum];
--
-- CheckFeatures();
--
-- if (( (int)outRectVid.x1 != OutWidth ) ||
-- ( (int)outRectVid.y1 != OutHeight ))
-- {
-- outRectVid.x0 = 0;
-- outRectVid.y0 = 0;
-- outRectVid.x1 = OutWidth;
-- outRectVid.y1 = OutHeight;
-- }
--
-- EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-- EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-- if (method == VS_INTERLACEMETHOD_AUTO)
-- method = AutoInterlaceMethod();
--
- if(pFrame)
- { // we have a new frame from decoder
-
-@@ -1349,7 +913,10 @@
- if(!render) // old style ffmpeg gave data on plane 0
- render = (vdpau_render_state*)pFrame->data[0];
- if(!render)
-+ {
-+ CLog::Log(LOGERROR, "CVDPAU::Decode: no valid frame");
- return VC_ERROR;
-+ }
-
- // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid
- if (!IsSurfaceValid(render))
-@@ -1358,256 +925,175 @@
- return VC_BUFFER;
- }
-
-+ CSingleLock lock(m_videoSurfaceSec);
- render->state |= FF_VDPAU_STATE_USED_FOR_RENDER;
-+ lock.Leave();
-+
-+ // send frame to output for processing
-+ CVdpauDecodedPicture pic;
-+ memset(&pic.DVDPic, 0, sizeof(pic.DVDPic));
-+ ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&pic.DVDPic);
-+ pic.render = render;
-+ m_bufferStats.IncDecoded();
-+ m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic));
-
-- ClearUsedForRender(&past[0]);
-- past[0] = past[1];
-- past[1] = current;
-- current = future;
-- future = render;
--
-- DVDVideoPicture DVDPic;
-- memset(&DVDPic, 0, sizeof(DVDVideoPicture));
-- ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&DVDPic);
-- m_DVDVideoPics.push(DVDPic);
--
-- int pics = m_DVDVideoPics.size();
-- if (pics < 2)
-- return VC_BUFFER;
-- else if (pics > 2)
-- {
-- // this should not normally happen
-- CLog::Log(LOGERROR, "CVDPAU::Decode - invalid number of pictures in queue");
-- while (pics-- != 2)
-- m_DVDVideoPics.pop();
-+ m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_SKIP_PROC);
-+ if (m_codecControl & DVP_FLAG_SKIP_PROC)
-+ {
-+ m_bufferStats.SetCmd(DVP_FLAG_SKIP_PROC);
- }
-+ }
-
-- if (mode == VS_DEINTERLACEMODE_FORCE
-- || (mode == VS_DEINTERLACEMODE_AUTO && m_DVDVideoPics.front().iFlags & DVP_FLAG_INTERLACED))
-+ int retval = 0;
-+ uint16_t decoded, processed, render;
-+ Message *msg;
-+ while (m_vdpauOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::ERROR)
- {
-- if((method == VS_INTERLACEMETHOD_VDPAU_BOB
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-- || method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE ))
-+ m_DisplayState = VDPAU_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+ msg->Release();
-+ }
-+
-+ m_bufferStats.Get(decoded, processed, render);
-+
-+ uint64_t startTime = CurrentHostCounter();
-+ while (!retval)
-+ {
-+ if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
- {
-- if(method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-- || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-- || avctx->skip_frame == AVDISCARD_NONREF)
-- m_mixerstep = 0;
-- else
-- m_mixerstep = 1;
--
-- if(m_DVDVideoPics.front().iFlags & DVP_FLAG_TOP_FIELD_FIRST)
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-- else
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-+ if (m_presentPicture)
-+ {
-+ m_presentPicture->ReturnUnused();
-+ m_presentPicture = 0;
-+ }
-+
-+ m_presentPicture = *(CVdpauRenderPicture**)msg->data;
-+ m_presentPicture->vdpau = this;
-+ m_bufferStats.DecRender();
-+ m_bufferStats.Get(decoded, processed, render);
-+ retval |= VC_PICTURE;
-+ msg->Release();
-+ break;
-+ }
-+ msg->Release();
-+ }
-+ else if (m_vdpauOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::STATS)
-+ {
-+ m_bufferStats.Get(decoded, processed, render);
- }
- else
- {
-- m_mixerstep = 0;
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ m_DisplayState = VDPAU_ERROR;
-+ retval |= VC_ERROR;
- }
-+ msg->Release();
- }
-- else
-+
-+ if ((m_codecControl & DVP_FLAG_DRAIN))
- {
-- m_mixerstep = 0;
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ if (decoded + processed + render < 4)
-+ {
-+ retval |= VC_BUFFER;
-+ }
- }
--
-- }
-- else if(m_mixerstep == 1)
-- { // no new frame given, output second field of old frame
--
-- if(avctx->skip_frame == AVDISCARD_NONREF)
-+ else
- {
-- ClearUsedForRender(&past[1]);
-- m_DVDVideoPics.pop();
-- return VC_BUFFER;
-+ if (decoded < 4 && (processed + render) < 3)
-+ {
-+ retval |= VC_BUFFER;
-+ }
- }
-
-- m_mixerstep = 2;
-- if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD)
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-- else
-- m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-+ if (!retval && !m_inMsgEvent.WaitMSec(2000))
-+ break;
- }
-- else
-+ uint64_t diff = CurrentHostCounter() - startTime;
-+ if (retval & VC_PICTURE)
- {
-- CLog::Log(LOGERROR, "CVDPAU::Decode - invalid mixer state reached");
-- return VC_BUFFER;
-+ m_bufferStats.SetParams(diff, m_speed);
- }
-+ if (diff*1000/CurrentHostFrequency() > 50)
-+ CLog::Log(LOGDEBUG,"CVDPAU::Decode long wait: %d", (int)((diff*1000)/CurrentHostFrequency()));
-
-- VdpVideoSurface past_surfaces[2] = { VDP_INVALID_HANDLE, VDP_INVALID_HANDLE };
-- VdpVideoSurface futu_surfaces[1] = { VDP_INVALID_HANDLE };
--
-- if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-- {
-- if (past[0])
-- past_surfaces[1] = past[0]->surface;
-- if (past[1])
-- past_surfaces[0] = past[1]->surface;
-- futu_surfaces[0] = future->surface;
-- }
-- else
-+ if (!retval)
- {
-- if(m_mixerstep == 1)
-- { // first field
-- if (past[1])
-- {
-- past_surfaces[1] = past[1]->surface;
-- past_surfaces[0] = past[1]->surface;
-- }
-- futu_surfaces[0] = current->surface;
-- }
-- else
-- { // second field
-- if (past[1])
-- past_surfaces[1] = past[1]->surface;
-- past_surfaces[0] = current->surface;
-- futu_surfaces[0] = future->surface;
-- }
-+ CLog::Log(LOGERROR, "VDPAU::%s - timed out waiting for output message", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
-+ retval |= VC_ERROR;
- }
-
-- vdp_st = vdp_presentation_queue_block_until_surface_idle(vdp_flip_queue,outputSurface,&time);
--
-- VdpRect sourceRect = {0,0,vid_width, vid_height};
--
-- vdp_st = vdp_video_mixer_render(videoMixer,
-- VDP_INVALID_HANDLE,
-- 0,
-- m_mixerfield,
-- 2,
-- past_surfaces,
-- current->surface,
-- 1,
-- futu_surfaces,
-- &sourceRect,
-- outputSurface,
-- &(outRectVid),
-- &(outRectVid),
-- 0,
-- NULL);
-- CheckStatus(vdp_st, __LINE__);
--
-- surfaceNum++;
-- if (surfaceNum >= totalAvailableOutputSurfaces) surfaceNum = 0;
-+ return retval;
-+}
-
-- if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-- {
-- ClearUsedForRender(&past[0]);
-- return VC_BUFFER | VC_PICTURE;
-- }
-- else
-- {
-- // in order to clip top and bottom lines when de-interlacing
-- // we black those lines as a work around for not working
-- // background colour using the mixer
-- // pixel perfect is preferred over overscanning or zooming
-+bool CDecoder::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
-+{
-+ CSingleLock lock(m_DecoderSection);
-
-- VdpRect clipRect = outRectVid;
-- clipRect.y1 = clipRect.y0 + 2;
-- uint32_t *data[] = {m_BlackBar};
-- uint32_t pitches[] = {outRectVid.x1};
-- vdp_st = vdp_output_surface_put_bits_native(outputSurface,
-- (void**)data,
-- pitches,
-- &clipRect);
-- CheckStatus(vdp_st, __LINE__);
-+ if (m_DisplayState != VDPAU_OPEN)
-+ return false;
-
-- clipRect = outRectVid;
-- clipRect.y0 = clipRect.y1 - 2;
-- vdp_st = vdp_output_surface_put_bits_native(outputSurface,
-- (void**)data,
-- pitches,
-- &clipRect);
-- CheckStatus(vdp_st, __LINE__);
-+ *picture = m_presentPicture->DVDPic;
-+ picture->vdpau = m_presentPicture;
-
-- if(m_mixerstep == 1)
-- return VC_PICTURE;
-- else
-- {
-- ClearUsedForRender(&past[1]);
-- return VC_BUFFER | VC_PICTURE;
-- }
-- }
-+ return true;
- }
-
--bool CVDPAU::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
-+void CDecoder::Reset()
- {
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return false;
-- }
-+ CSingleLock lock(m_DecoderSection);
-
-- *picture = m_DVDVideoPics.front();
-- // if this is the first field of an interlaced frame, we'll need
-- // this same picture for the second field later
-- if (m_mixerstep != 1)
-- m_DVDVideoPics.pop();
--
-- picture->format = DVDVideoPicture::FMT_VDPAU;
-- picture->iFlags &= DVP_FLAG_DROPPED;
-- picture->iWidth = OutWidth;
-- picture->iHeight = OutHeight;
-- picture->vdpau = this;
-+ if (!m_vdpauConfigured)
-+ return;
-
-- if(m_mixerstep)
-- {
-- picture->iRepeatPicture = -0.5;
-- if(m_mixerstep > 1)
-+ Message *reply;
-+ if (m_vdpauOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::FLUSH,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
- {
-- picture->dts = DVD_NOPTS_VALUE;
-- picture->pts = DVD_NOPTS_VALUE;
-+ CLog::Log(LOGERROR, "VDPAU::%s - flush returned error", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
- }
-+ else
-+ m_bufferStats.Reset();
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::%s - flush timed out", __FUNCTION__);
-+ m_DisplayState = VDPAU_ERROR;
- }
-- return true;
- }
-
--void CVDPAU::Reset()
-+bool CDecoder::CanSkipDeint()
- {
-- // invalidate surfaces and picture queue when seeking
-- ClearUsedForRender(&past[0]);
-- ClearUsedForRender(&past[1]);
-- ClearUsedForRender(¤t);
-- ClearUsedForRender(&future);
--
-- while (!m_DVDVideoPics.empty())
-- m_DVDVideoPics.pop();
-+ return m_bufferStats.CanSkipDeint();
- }
-
--void CVDPAU::Present()
-+void CDecoder::SetSpeed(int speed)
- {
-- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
-- VdpStatus vdp_st;
--
-- CSharedLock lock(m_DecoderSection);
--
-- { CSharedLock dLock(m_DisplaySection);
-- if (m_DisplayState != VDPAU_OPEN)
-- return;
-- }
--
-- presentSurface = outputSurface;
-+ m_speed = speed;
-+}
-
-- vdp_st = vdp_presentation_queue_display(vdp_flip_queue,
-- presentSurface,
-- 0,
-- 0,
-- 0);
-- CheckStatus(vdp_st, __LINE__);
-+void CDecoder::ReturnRenderPicture(CVdpauRenderPicture *renderPic)
-+{
-+ m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::RETURNPIC, &renderPic, sizeof(renderPic));
- }
-
--bool CVDPAU::CheckStatus(VdpStatus vdp_st, int line)
-+bool CDecoder::CheckStatus(VdpStatus vdp_st, int line)
- {
- if (vdp_st != VDP_STATUS_OK)
- {
-- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
--
-- CExclusiveLock lock(m_DisplaySection);
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
-
- if(m_DisplayState == VDPAU_OPEN)
- {
-@@ -1625,4 +1111,2432 @@
- return false;
- }
-
-+//-----------------------------------------------------------------------------
-+// RenderPicture
-+//-----------------------------------------------------------------------------
-+
-+CVdpauRenderPicture* CVdpauRenderPicture::Acquire()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ if (refCount == 0)
-+ vdpau->Acquire();
-+
-+ refCount++;
-+ return this;
-+}
-+
-+long CVdpauRenderPicture::Release()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ refCount--;
-+ if (refCount > 0)
-+ return refCount;
-+
-+ lock.Leave();
-+ vdpau->ReturnRenderPicture(this);
-+ vdpau->ReleasePicReference();
-+
-+ return refCount;
-+}
-+
-+void CVdpauRenderPicture::ReturnUnused()
-+{
-+ { CSingleLock lock(*renderPicSection);
-+ if (refCount > 0)
-+ return;
-+ }
-+ if (vdpau)
-+ vdpau->ReturnRenderPicture(this);
-+}
-+
-+//-----------------------------------------------------------------------------
-+// Mixer
-+//-----------------------------------------------------------------------------
-+CMixer::CMixer(CEvent *inMsgEvent) :
-+ CThread("Vdpau Mixer Thread"),
-+ m_controlPort("ControlPort", inMsgEvent, &m_outMsgEvent),
-+ m_dataPort("DataPort", inMsgEvent, &m_outMsgEvent)
-+{
-+ m_inMsgEvent = inMsgEvent;
-+}
-+
-+CMixer::~CMixer()
-+{
-+ Dispose();
-+}
-+
-+void CMixer::Start()
-+{
-+ Create();
-+}
-+
-+void CMixer::Dispose()
-+{
-+ m_bStop = true;
-+ m_outMsgEvent.Set();
-+ StopThread();
-+
-+ m_controlPort.Purge();
-+ m_dataPort.Purge();
-+}
-+
-+void CMixer::OnStartup()
-+{
-+ CLog::Log(LOGNOTICE, "CMixer::OnStartup: Output Thread created");
-+}
-+
-+void CMixer::OnExit()
-+{
-+ CLog::Log(LOGNOTICE, "CMixer::OnExit: Output Thread terminated");
-+}
-+
-+enum MIXER_STATES
-+{
-+ M_TOP = 0, // 0
-+ M_TOP_ERROR, // 1
-+ M_TOP_UNCONFIGURED, // 2
-+ M_TOP_CONFIGURED, // 3
-+ M_TOP_CONFIGURED_WAIT1, // 4
-+ M_TOP_CONFIGURED_STEP1, // 5
-+ M_TOP_CONFIGURED_WAIT2, // 6
-+ M_TOP_CONFIGURED_STEP2, // 7
-+};
-+
-+int MIXER_parentStates[] = {
-+ -1,
-+ 0, //TOP_ERROR
-+ 0, //TOP_UNCONFIGURED
-+ 0, //TOP_CONFIGURED
-+ 3, //TOP_CONFIGURED_WAIT1
-+ 3, //TOP_CONFIGURED_STEP1
-+ 3, //TOP_CONFIGURED_WAIT2
-+ 3, //TOP_CONFIGURED_STEP2
-+};
-+
-+void CMixer::StateMachine(int signal, Protocol *port, Message *msg)
-+{
-+ for (int state = m_state; ; state = MIXER_parentStates[state])
-+ {
-+ switch (state)
-+ {
-+ case M_TOP: // TOP
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::FLUSH:
-+ Flush();
-+ msg->Reply(CMixerControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ {
-+ std::string portName = port == NULL ? "timer" : port->portName;
-+ CLog::Log(LOGWARNING, "CMixer::%s - signal: %d form port: %s not handled for state: %d", __FUNCTION__, signal, portName.c_str(), m_state);
-+ }
-+ return;
-+
-+ case M_TOP_ERROR: // TOP
-+ break;
-+
-+ case M_TOP_UNCONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::INIT:
-+ CVdpauConfig *data;
-+ data = (CVdpauConfig*)msg->data;
-+ if (data)
-+ {
-+ m_config = *data;
-+ }
-+ Init();
-+ if (!m_vdpError)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ msg->Reply(CMixerControlProtocol::ACC);
-+ }
-+ else
-+ {
-+ msg->Reply(CMixerControlProtocol::ERROR);
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED:
-+ if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerDataProtocol::FRAME:
-+ CVdpauDecodedPicture *frame;
-+ frame = (CVdpauDecodedPicture*)msg->data;
-+ if (frame)
-+ {
-+ m_decodedPics.push(*frame);
-+ }
-+ m_extTimeout = 0;
-+ return;
-+ case CMixerDataProtocol::BUFFER:
-+ VdpOutputSurface *surf;
-+ surf = (VdpOutputSurface*)msg->data;
-+ if (surf)
-+ {
-+ m_outputSurfaces.push(*surf);
-+ }
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_WAIT1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ if (!m_decodedPics.empty() && !m_outputSurfaces.empty())
-+ {
-+ m_state = M_TOP_CONFIGURED_STEP1;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+// if (m_extTimeout != 0)
-+// {
-+// SetPostProcFeatures(false);
-+// CLog::Log(LOGWARNING,"CVDPAU::Mixer timeout - decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size());
-+// }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_STEP1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ m_mixerInput.push_front(m_decodedPics.front());
-+ m_decodedPics.pop();
-+ if (m_mixerInput.size() < 2)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 0;
-+ return;
-+ }
-+ InitCycle();
-+ ProcessPicture();
-+ if (m_vdpError)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 1000;
-+ return;
-+ }
-+ if (m_processPicture.DVDPic.format != DVDVideoPicture::FMT_VDPAU_420)
-+ m_outputSurfaces.pop();
-+ m_config.stats->IncProcessed();
-+ m_config.stats->DecDecoded();
-+ m_dataPort.SendInMessage(CMixerDataProtocol::PICTURE,&m_processPicture,sizeof(m_processPicture));
-+ if (m_mixersteps > 1)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT2;
-+ m_extTimeout = 0;
-+ }
-+ else
-+ {
-+ FiniCycle();
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 0;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_WAIT2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ if (!m_outputSurfaces.empty())
-+ {
-+ m_state = M_TOP_CONFIGURED_STEP2;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+// if (m_extTimeout != 0)
-+// {
-+// SetPostProcFeatures(false);
-+// CLog::Log(LOGNOTICE,"---mixer wait2 decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size());
-+// }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case M_TOP_CONFIGURED_STEP2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case CMixerControlProtocol::TIMEOUT:
-+ m_processPicture.outputSurface = m_outputSurfaces.front();
-+ m_mixerstep = 1;
-+ ProcessPicture();
-+ if (m_vdpError)
-+ {
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 1000;
-+ return;
-+ }
-+ if (m_processPicture.DVDPic.format != DVDVideoPicture::FMT_VDPAU_420)
-+ m_outputSurfaces.pop();
-+ m_config.stats->IncProcessed();
-+ m_dataPort.SendInMessage(CMixerDataProtocol::PICTURE,&m_processPicture,sizeof(m_processPicture));
-+ FiniCycle();
-+ m_state = M_TOP_CONFIGURED_WAIT1;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ default: // we are in no state, should not happen
-+ CLog::Log(LOGERROR, "CMixer::%s - no valid state: %d", __FUNCTION__, m_state);
-+ return;
-+ }
-+ } // for
-+}
-+
-+void CMixer::Process()
-+{
-+ Message *msg;
-+ Protocol *port;
-+ bool gotMsg;
-+
-+ m_state = M_TOP_UNCONFIGURED;
-+ m_extTimeout = 1000;
-+ m_bStateMachineSelfTrigger = false;
-+
-+ while (!m_bStop)
-+ {
-+ gotMsg = false;
-+
-+ if (m_bStateMachineSelfTrigger)
-+ {
-+ m_bStateMachineSelfTrigger = false;
-+ // self trigger state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+ // check control port
-+ else if (m_controlPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_controlPort;
-+ }
-+ // check data port
-+ else if (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_dataPort;
-+ }
-+
-+ if (gotMsg)
-+ {
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+
-+ // wait for message
-+ else if (m_outMsgEvent.WaitMSec(m_extTimeout))
-+ {
-+ continue;
-+ }
-+ // time out
-+ else
-+ {
-+ msg = m_controlPort.GetMessage();
-+ msg->signal = CMixerControlProtocol::TIMEOUT;
-+ port = 0;
-+ // signal timeout to state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ }
-+ }
-+ Uninit();
-+}
-+
-+void CMixer::CreateVdpauMixer()
-+{
-+ CLog::Log(LOGNOTICE, " (VDPAU) Creating the video mixer");
-+
-+ InitCSCMatrix(m_config.vidWidth);
-+
-+ VdpVideoMixerParameter parameters[] = {
-+ VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
-+ VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
-+ VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE};
-+
-+ void const * parameter_values[] = {
-+ &m_config.surfaceWidth,
-+ &m_config.surfaceHeight,
-+ &m_config.vdpChromaType};
-+
-+ VdpStatus vdp_st = VDP_STATUS_ERROR;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_create(m_config.vdpDevice,
-+ m_config.featureCount,
-+ m_config.vdpFeatures,
-+ ARSIZE(parameters),
-+ parameters,
-+ parameter_values,
-+ &m_videoMixer);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ // create 3 pitches of black lines needed for clipping top
-+ // and bottom lines when de-interlacing
-+ m_BlackBar = new uint32_t[3*m_config.outWidth];
-+ memset(m_BlackBar, 0, 3*m_config.outWidth*sizeof(uint32_t));
-+
-+}
-+
-+void CMixer::InitCSCMatrix(int Width)
-+{
-+ VdpStatus vdp_st;
-+ m_Procamp.struct_version = VDP_PROCAMP_VERSION;
-+ m_Procamp.brightness = 0.0;
-+ m_Procamp.contrast = 1.0;
-+ m_Procamp.saturation = 1.0;
-+ m_Procamp.hue = 0;
-+ vdp_st = m_config.vdpProcs.vdp_generate_csc_matrix(&m_Procamp,
-+ (Width < 1000)? VDP_COLOR_STANDARD_ITUR_BT_601 : VDP_COLOR_STANDARD_ITUR_BT_709,
-+ &m_CSCMatrix);
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::CheckFeatures()
-+{
-+ if (m_Upscale != m_config.upscale)
-+ {
-+ SetHWUpscaling();
-+ m_Upscale = m_config.upscale;
-+ }
-+ if (m_Brightness != g_settings.m_currentVideoSettings.m_Brightness ||
-+ m_Contrast != g_settings.m_currentVideoSettings.m_Contrast)
-+ {
-+ SetColor();
-+ m_Brightness = g_settings.m_currentVideoSettings.m_Brightness;
-+ m_Contrast = g_settings.m_currentVideoSettings.m_Contrast;
-+ }
-+ if (m_NoiseReduction != g_settings.m_currentVideoSettings.m_NoiseReduction)
-+ {
-+ m_NoiseReduction = g_settings.m_currentVideoSettings.m_NoiseReduction;
-+ SetNoiseReduction();
-+ }
-+ if (m_Sharpness != g_settings.m_currentVideoSettings.m_Sharpness)
-+ {
-+ m_Sharpness = g_settings.m_currentVideoSettings.m_Sharpness;
-+ SetSharpness();
-+ }
-+ if (m_DeintMode != g_settings.m_currentVideoSettings.m_DeinterlaceMode ||
-+ m_Deint != g_settings.m_currentVideoSettings.m_InterlaceMethod)
-+ {
-+ m_DeintMode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ m_Deint = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-+ SetDeinterlacing();
-+ }
-+}
-+
-+void CMixer::SetPostProcFeatures(bool postProcEnabled)
-+{
-+ if (m_PostProc != postProcEnabled)
-+ {
-+ if (postProcEnabled)
-+ {
-+ SetNoiseReduction();
-+ SetSharpness();
-+ SetDeinterlacing();
-+ SetHWUpscaling();
-+ }
-+ else
-+ PostProcOff();
-+ m_PostProc = postProcEnabled;
-+ }
-+}
-+
-+void CMixer::PostProcOff()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_videoMixer == VDP_INVALID_HANDLE)
-+ return;
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
-+ VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
-+ VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE};
-+
-+ VdpBool enabled[]={0,0,0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION};
-+
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS};
-+
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ DisableHQScaling();
-+}
-+
-+
-+bool CMixer::GenerateStudioCSCMatrix(VdpColorStandard colorStandard, VdpCSCMatrix &studioCSCMatrix)
-+{
-+ // instead use studioCSCKCoeffs601[3], studioCSCKCoeffs709[3] to generate float[3][4] matrix (float studioCSC[3][4])
-+ // m00 = mRY = red: luma factor (contrast factor) (1.0)
-+ // m10 = mGY = green: luma factor (contrast factor) (1.0)
-+ // m20 = mBY = blue: luma factor (contrast factor) (1.0)
-+ //
-+ // m01 = mRB = red: blue color diff coeff (0.0)
-+ // m11 = mGB = green: blue color diff coeff (-2Kb(1-Kb)/(Kg))
-+ // m21 = mBB = blue: blue color diff coeff ((1-Kb)/0.5)
-+ //
-+ // m02 = mRR = red: red color diff coeff ((1-Kr)/0.5)
-+ // m12 = mGR = green: red color diff coeff (-2Kr(1-Kr)/(Kg))
-+ // m22 = mBR = blue: red color diff coeff (0.0)
-+ //
-+ // m03 = mRC = red: colour zero offset (brightness factor) (-(1-Kr)/0.5 * (128/255))
-+ // m13 = mGC = green: colour zero offset (brightness factor) ((256/255) * (Kb(1-Kb) + Kr(1-Kr)) / Kg)
-+ // m23 = mBC = blue: colour zero offset (brightness factor) (-(1-Kb)/0.5 * (128/255))
-+
-+ // columns
-+ int Y = 0;
-+ int Cb = 1;
-+ int Cr = 2;
-+ int C = 3;
-+ // rows
-+ int R = 0;
-+ int G = 1;
-+ int B = 2;
-+ // colour standard coefficients for red, geen, blue
-+ double Kr, Kg, Kb;
-+ // colour diff zero position (use standard 8-bit coding precision)
-+ double CDZ = 128; //256*0.5
-+ // range excursion (use standard 8-bit coding precision)
-+ double EXC = 255; //256-1
-+
-+ if (colorStandard == VDP_COLOR_STANDARD_ITUR_BT_601)
-+ {
-+ Kr = studioCSCKCoeffs601[0];
-+ Kg = studioCSCKCoeffs601[1];
-+ Kb = studioCSCKCoeffs601[2];
-+ }
-+ else // assume VDP_COLOR_STANDARD_ITUR_BT_709
-+ {
-+ Kr = studioCSCKCoeffs709[0];
-+ Kg = studioCSCKCoeffs709[1];
-+ Kb = studioCSCKCoeffs709[2];
-+ }
-+ // we keep luma unscaled to retain the levels present in source so that 16-235 luma is converted to RGB 16-235
-+ studioCSCMatrix[R][Y] = 1.0;
-+ studioCSCMatrix[G][Y] = 1.0;
-+ studioCSCMatrix[B][Y] = 1.0;
-+
-+ studioCSCMatrix[R][Cb] = 0.0;
-+ studioCSCMatrix[G][Cb] = (double)-2 * Kb * (1 - Kb) / Kg;
-+ studioCSCMatrix[B][Cb] = (double)(1 - Kb) / 0.5;
-+
-+ studioCSCMatrix[R][Cr] = (double)(1 - Kr) / 0.5;
-+ studioCSCMatrix[G][Cr] = (double)-2 * Kr * (1 - Kr) / Kg;
-+ studioCSCMatrix[B][Cr] = 0.0;
-+
-+ studioCSCMatrix[R][C] = (double)-1 * studioCSCMatrix[R][Cr] * CDZ/EXC;
-+ studioCSCMatrix[G][C] = (double)-1 * (studioCSCMatrix[G][Cb] + studioCSCMatrix[G][Cr]) * CDZ/EXC;
-+ studioCSCMatrix[B][C] = (double)-1 * studioCSCMatrix[B][Cb] * CDZ/EXC;
-+
-+ return true;
-+}
-+
-+void CMixer::SetColor()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_Brightness != g_settings.m_currentVideoSettings.m_Brightness)
-+ m_Procamp.brightness = (float)((g_settings.m_currentVideoSettings.m_Brightness)-50) / 100;
-+ if (m_Contrast != g_settings.m_currentVideoSettings.m_Contrast)
-+ m_Procamp.contrast = (float)((g_settings.m_currentVideoSettings.m_Contrast)+50) / 100;
-+
-+ VdpColorStandard colorStandard;
-+// if(vid_height >= 600 || vid_width > 1024)
-+ if(m_config.surfaceWidth > 1000)
-+ colorStandard = VDP_COLOR_STANDARD_ITUR_BT_709;
-+ //vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_709, &m_CSCMatrix);
-+ else
-+ colorStandard = VDP_COLOR_STANDARD_ITUR_BT_601;
-+ //vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_601, &m_CSCMatrix);
-+
-+ VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX };
-+ if (g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
-+ {
-+ float studioCSC[3][4];
-+ GenerateStudioCSCMatrix(colorStandard, studioCSC);
-+ void const * pm_CSCMatix[] = { &studioCSC };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-+ }
-+ else
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix);
-+ void const * pm_CSCMatix[] = { &m_CSCMatrix };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
-+ }
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::SetNoiseReduction()
-+{
-+ if(!m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
-+ return;
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION };
-+ VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_NOISE_REDUCTION_LEVEL };
-+ VdpStatus vdp_st;
-+
-+ if (!g_settings.m_currentVideoSettings.m_NoiseReduction)
-+ {
-+ VdpBool enabled[]= {0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ return;
-+ }
-+ VdpBool enabled[]={1};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ void* nr[] = { &g_settings.m_currentVideoSettings.m_NoiseReduction };
-+ CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",g_settings.m_currentVideoSettings.m_NoiseReduction);
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr);
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::SetSharpness()
-+{
-+ if(!m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_SHARPNESS))
-+ return;
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS };
-+ VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_SHARPNESS_LEVEL };
-+ VdpStatus vdp_st;
-+
-+ if (!g_settings.m_currentVideoSettings.m_Sharpness)
-+ {
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ return;
-+ }
-+ VdpBool enabled[]={1};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ void* sh[] = { &g_settings.m_currentVideoSettings.m_Sharpness };
-+ CLog::Log(LOGNOTICE,"Setting Sharpness to %f",g_settings.m_currentVideoSettings.m_Sharpness);
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh);
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+EINTERLACEMETHOD CMixer::GetDeinterlacingMethod(bool log /* = false */)
-+{
-+ EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-+ if (method == VS_INTERLACEMETHOD_AUTO)
-+ {
-+ int deint = -1;
-+ if (m_config.outHeight >= 720)
-+ deint = g_advancedSettings.m_videoVDPAUdeintHD;
-+ else
-+ deint = g_advancedSettings.m_videoVDPAUdeintSD;
-+
-+ if (deint != -1)
-+ {
-+ if (m_config.vdpau->Supports(EINTERLACEMETHOD(deint)))
-+ {
-+ method = EINTERLACEMETHOD(deint);
-+ if (log)
-+ CLog::Log(LOGNOTICE, "CVDPAU::GetDeinterlacingMethod: set de-interlacing to %d", deint);
-+ }
-+ else
-+ {
-+ if (log)
-+ CLog::Log(LOGWARNING, "CVDPAU::GetDeinterlacingMethod: method for de-interlacing (advanced settings) not supported");
-+ }
-+ }
-+ }
-+ return method;
-+}
-+
-+void CMixer::SetDeinterlacing()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_videoMixer == VDP_INVALID_HANDLE)
-+ return;
-+
-+ EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ EINTERLACEMETHOD method = GetDeinterlacingMethod(true);
-+
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
-+ VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
-+ VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE };
-+
-+ if (mode == VS_DEINTERLACEMODE_OFF)
-+ {
-+ VdpBool enabled[] = {0,0,0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else
-+ {
-+ if (method == VS_INTERLACEMETHOD_AUTO)
-+ {
-+ VdpBool enabled[] = {1,1,0};
-+ if (g_advancedSettings.m_videoVDPAUtelecine)
-+ enabled[2] = 1;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF)
-+ {
-+ VdpBool enabled[] = {1,0,0};
-+ if (g_advancedSettings.m_videoVDPAUtelecine)
-+ enabled[2] = 1;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF)
-+ {
-+ VdpBool enabled[] = {1,1,0};
-+ if (g_advancedSettings.m_videoVDPAUtelecine)
-+ enabled[2] = 1;
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ else
-+ {
-+ VdpBool enabled[]={0,0,0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ }
-+ }
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ SetDeintSkipChroma();
-+
-+ m_config.useInteropYuv = g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
-+}
-+
-+void CMixer::SetDeintSkipChroma()
-+{
-+ VdpVideoMixerAttribute attribute[] = { VDP_VIDEO_MIXER_ATTRIBUTE_SKIP_CHROMA_DEINTERLACE};
-+ VdpStatus vdp_st;
-+
-+ uint8_t val;
-+ if (g_advancedSettings.m_videoVDPAUdeintSkipChromaHD && m_config.outHeight >= 720)
-+ val = 1;
-+ else
-+ val = 0;
-+
-+ void const *values[]={&val};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values);
-+
-+ CheckStatus(vdp_st, __LINE__);
-+}
-+
-+void CMixer::SetHWUpscaling()
-+{
-+#ifdef VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1
-+
-+ VdpStatus vdp_st;
-+ VdpBool enabled[]={1};
-+ switch (m_config.upscale)
-+ {
-+ case 9:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 8:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 7:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 6:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 5:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 4:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 3:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 2:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ case 1:
-+ if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ break;
-+ }
-+ default:
-+ DisableHQScaling();
-+ return;
-+ }
-+ CheckStatus(vdp_st, __LINE__);
-+#endif
-+}
-+
-+void CMixer::DisableHQScaling()
-+{
-+ VdpStatus vdp_st;
-+
-+ if (m_videoMixer == VDP_INVALID_HANDLE)
-+ return;
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+
-+ if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9))
-+ {
-+ VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 };
-+ VdpBool enabled[]={0};
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+}
-+
-+
-+void CMixer::Init()
-+{
-+ m_Brightness = 0.0;
-+ m_Contrast = 0.0;
-+ m_NoiseReduction = 0.0;
-+ m_Sharpness = 0.0;
-+ m_DeintMode = 0;
-+ m_Deint = 0;
-+ m_PostProc = false;
-+ m_vdpError = false;
-+
-+ m_config.upscale = g_advancedSettings.m_videoVDPAUScaling;
-+ m_config.useInteropYuv = g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
-+
-+ CreateVdpauMixer();
-+}
-+
-+void CMixer::Uninit()
-+{
-+ Flush();
-+ while (!m_outputSurfaces.empty())
-+ {
-+ m_outputSurfaces.pop();
-+ }
-+ m_config.vdpProcs.vdp_video_mixer_destroy(m_videoMixer);
-+}
-+
-+void CMixer::Flush()
-+{
-+ while (!m_mixerInput.empty())
-+ {
-+ CVdpauDecodedPicture pic = m_mixerInput.back();
-+ m_mixerInput.pop_back();
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ while (!m_decodedPics.empty())
-+ {
-+ CVdpauDecodedPicture pic = m_decodedPics.front();
-+ m_decodedPics.pop();
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ Message *msg;
-+ while (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ if (msg->signal == CMixerDataProtocol::FRAME)
-+ {
-+ CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ else if (msg->signal == CMixerDataProtocol::BUFFER)
-+ {
-+ VdpOutputSurface *surf;
-+ surf = (VdpOutputSurface*)msg->data;
-+ m_outputSurfaces.push(*surf);
-+ }
-+ msg->Release();
-+ }
-+}
-+
-+void CMixer::InitCycle()
-+{
-+ CheckFeatures();
-+ uint64_t latency;
-+ int speed;
-+ m_config.stats->GetParams(latency, speed);
-+ latency = (latency*1000)/CurrentHostFrequency();
-+ if (speed != DVD_PLAYSPEED_NORMAL)
-+ SetPostProcFeatures(false);
-+ else
-+ SetPostProcFeatures(true);
-+
-+ m_config.stats->SetCanSkipDeint(false);
-+
-+ EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ EINTERLACEMETHOD method = GetDeinterlacingMethod();
-+ bool interlaced = m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_INTERLACED;
-+
-+ if (mode == VS_DEINTERLACEMODE_FORCE ||
-+ (mode == VS_DEINTERLACEMODE_AUTO && interlaced))
-+ {
-+ if((method == VS_INTERLACEMETHOD_AUTO && interlaced)
-+ || method == VS_INTERLACEMETHOD_VDPAU_BOB
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-+ || method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE )
-+ {
-+ if(method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF
-+ || method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF
-+ || !g_graphicsContext.IsFullScreenVideo())
-+ m_mixersteps = 1;
-+ else
-+ {
-+ m_mixersteps = 2;
-+ m_config.stats->SetCanSkipDeint(true);
-+ }
-+
-+ if (m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_DROPDEINT)
-+ {
-+ m_mixersteps = 1;
-+ }
-+
-+ if(m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-+ else
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-+
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU;
-+ m_mixerInput[1].DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ m_config.useInteropYuv = false;
-+ }
-+ else if (method == VS_INTERLACEMETHOD_RENDER_BOB && m_config.useInteropYuv)
-+ {
-+ m_mixersteps = 1;
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU_420;
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "CMixer::%s - interlace method not supported", __FUNCTION__);
-+ m_mixersteps = 1;
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU;
-+ m_mixerInput[1].DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ }
-+ }
-+ else
-+ {
-+ m_mixersteps = 1;
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME;
-+
-+ if (m_config.useInteropYuv)
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU_420;
-+ else
-+ {
-+ m_mixerInput[1].DVDPic.format = DVDVideoPicture::FMT_VDPAU;
-+ m_mixerInput[1].DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ }
-+ }
-+ m_mixerstep = 0;
-+
-+ if (m_mixerInput[1].DVDPic.format == DVDVideoPicture::FMT_VDPAU)
-+ {
-+ m_processPicture.outputSurface = m_outputSurfaces.front();
-+ m_mixerInput[1].DVDPic.iWidth = m_config.outWidth;
-+ m_mixerInput[1].DVDPic.iHeight = m_config.outHeight;
-+ }
-+ else
-+ {
-+ m_mixerInput[1].DVDPic.iWidth = m_config.vidWidth;
-+ m_mixerInput[1].DVDPic.iHeight = m_config.vidHeight;
-+ }
-+
-+ m_processPicture.DVDPic = m_mixerInput[1].DVDPic;
-+ m_processPicture.render = m_mixerInput[1].render;
-+}
-+
-+void CMixer::FiniCycle()
-+{
-+ while (m_mixerInput.size() > 3)
-+ {
-+ CVdpauDecodedPicture &tmp = m_mixerInput.back();
-+ if (tmp.render && m_processPicture.DVDPic.format != DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ tmp.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ m_mixerInput.pop_back();
-+// m_config.stats->DecDecoded();
-+ }
-+}
-+
-+void CMixer::ProcessPicture()
-+{
-+ if (m_processPicture.DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ return;
-+
-+ int cmd = 0;
-+ m_config.stats->GetCmd(cmd);
-+ if (cmd & DVP_FLAG_SKIP_PROC)
-+ {
-+ m_processPicture.DVDPic.iFlags |= DVP_FLAG_DROPPED;
-+ return;
-+ }
-+
-+ VdpStatus vdp_st;
-+
-+ if (m_mixerstep == 1)
-+ {
-+ if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD)
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD;
-+ else
-+ m_mixerfield = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD;
-+ }
-+
-+ VdpVideoSurface past_surfaces[4] = { VDP_INVALID_HANDLE, VDP_INVALID_HANDLE, VDP_INVALID_HANDLE, VDP_INVALID_HANDLE };
-+ VdpVideoSurface futu_surfaces[2] = { VDP_INVALID_HANDLE, VDP_INVALID_HANDLE };
-+ uint32_t pastCount = 4;
-+ uint32_t futuCount = 2;
-+
-+ if(m_mixerfield == VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-+ {
-+ // use only 2 past 1 future for progressive/weave
-+ // (only used for postproc anyway eg noise reduction)
-+ if (m_mixerInput.size() > 3)
-+ past_surfaces[1] = m_mixerInput[3].render->surface;
-+ if (m_mixerInput.size() > 2)
-+ past_surfaces[0] = m_mixerInput[2].render->surface;
-+ futu_surfaces[0] = m_mixerInput[0].render->surface;
-+ pastCount = 2;
-+ futuCount = 1;
-+ }
-+ else
-+ {
-+ if(m_mixerstep == 0)
-+ { // first field
-+ if (m_mixerInput.size() > 3)
-+ {
-+ past_surfaces[3] = m_mixerInput[3].render->surface;
-+ past_surfaces[2] = m_mixerInput[3].render->surface;
-+ }
-+ if (m_mixerInput.size() > 2)
-+ {
-+ past_surfaces[1] = m_mixerInput[2].render->surface;
-+ past_surfaces[0] = m_mixerInput[2].render->surface;
-+ }
-+ futu_surfaces[0] = m_mixerInput[1].render->surface;
-+ futu_surfaces[1] = m_mixerInput[0].render->surface;;
-+ }
-+ else
-+ { // second field
-+ if (m_mixerInput.size() > 3)
-+ {
-+ past_surfaces[3] = m_mixerInput[3].render->surface;
-+ }
-+ if (m_mixerInput.size() > 2)
-+ {
-+ past_surfaces[2] = m_mixerInput[2].render->surface;
-+ past_surfaces[1] = m_mixerInput[2].render->surface;
-+ }
-+ past_surfaces[0] = m_mixerInput[1].render->surface;
-+ futu_surfaces[0] = m_mixerInput[1].render->surface;
-+ futu_surfaces[1] = m_mixerInput[1].render->surface;
-+
-+ m_processPicture.DVDPic.pts = DVD_NOPTS_VALUE;
-+ m_processPicture.DVDPic.dts = DVD_NOPTS_VALUE;
-+ }
-+ m_processPicture.DVDPic.iRepeatPicture = 0.0;
-+ } // interlaced
-+
-+ VdpRect sourceRect;
-+ sourceRect.x0 = 0;
-+ sourceRect.y0 = 0;
-+ sourceRect.x1 = m_config.vidWidth;
-+ sourceRect.y1 = m_config.vidHeight;
-+
-+ VdpRect destRect;
-+ destRect.x0 = 0;
-+ destRect.y0 = 0;
-+ destRect.x1 = m_config.outWidth;
-+ destRect.y1 = m_config.outHeight;
-+
-+ // start vdpau video mixer
-+ vdp_st = m_config.vdpProcs.vdp_video_mixer_render(m_videoMixer,
-+ VDP_INVALID_HANDLE,
-+ 0,
-+ m_mixerfield,
-+ pastCount,
-+ past_surfaces,
-+ m_mixerInput[1].render->surface,
-+ futuCount,
-+ futu_surfaces,
-+ &sourceRect,
-+ m_processPicture.outputSurface,
-+ &destRect,
-+ &destRect,
-+ 0,
-+ NULL);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ if (m_mixerfield != VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
-+ {
-+ // in order to clip top and bottom lines when de-interlacing
-+ // we black those lines as a work around for not working
-+ // background colour using the mixer
-+ // pixel perfect is preferred over overscanning or zooming
-+
-+ VdpRect clipRect = destRect;
-+ clipRect.y1 = clipRect.y0 + 2;
-+ uint32_t *data[] = {m_BlackBar};
-+ uint32_t pitches[] = {destRect.x1};
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
-+ (void**)data,
-+ pitches,
-+ &clipRect);
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ clipRect = destRect;
-+ clipRect.y0 = clipRect.y1 - 2;
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
-+ (void**)data,
-+ pitches,
-+ &clipRect);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+}
-+
-+
-+bool CMixer::CheckStatus(VdpStatus vdp_st, int line)
-+{
-+ if (vdp_st != VDP_STATUS_OK)
-+ {
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
-+ m_vdpError = true;
-+ return true;
-+ }
-+ return false;
-+}
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+COutput::COutput(CEvent *inMsgEvent) :
-+ CThread("Vdpau Output Thread"),
-+ m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent),
-+ m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent),
-+ m_mixer(&m_outMsgEvent)
-+{
-+ m_inMsgEvent = inMsgEvent;
-+
-+ CVdpauRenderPicture pic;
-+ pic.renderPicSection = &m_bufferPool.renderPicSec;
-+ pic.refCount = 0;
-+ for (unsigned int i = 0; i < NUM_RENDER_PICS; i++)
-+ {
-+ m_bufferPool.allRenderPics.push_back(pic);
-+ }
-+ for (unsigned int i = 0; i < m_bufferPool.allRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.freeRenderPics.push_back(&m_bufferPool.allRenderPics[i]);
-+ }
-+}
-+
-+void COutput::Start()
-+{
-+ Create();
-+}
-+
-+COutput::~COutput()
-+{
-+ Dispose();
-+
-+ m_bufferPool.freeRenderPics.clear();
-+ m_bufferPool.usedRenderPics.clear();
-+ m_bufferPool.allRenderPics.clear();
-+}
-+
-+void COutput::Dispose()
-+{
-+ CSingleLock lock(g_graphicsContext);
-+ m_bStop = true;
-+ m_outMsgEvent.Set();
-+ StopThread();
-+ m_controlPort.Purge();
-+ m_dataPort.Purge();
-+}
-+
-+void COutput::OnStartup()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnStartup: Output Thread created");
-+}
-+
-+void COutput::OnExit()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnExit: Output Thread terminated");
-+}
-+
-+enum OUTPUT_STATES
-+{
-+ O_TOP = 0, // 0
-+ O_TOP_ERROR, // 1
-+ O_TOP_UNCONFIGURED, // 2
-+ O_TOP_CONFIGURED, // 3
-+ O_TOP_CONFIGURED_IDLE, // 4
-+ O_TOP_CONFIGURED_WORK, // 5
-+};
-+
-+int VDPAU_OUTPUT_parentStates[] = {
-+ -1,
-+ 0, //TOP_ERROR
-+ 0, //TOP_UNCONFIGURED
-+ 0, //TOP_CONFIGURED
-+ 3, //TOP_CONFIGURED_IDLE
-+ 3, //TOP_CONFIGURED_WORK
-+};
-+
-+void COutput::StateMachine(int signal, Protocol *port, Message *msg)
-+{
-+ for (int state = m_state; ; state = VDPAU_OUTPUT_parentStates[state])
-+ {
-+ switch (state)
-+ {
-+ case O_TOP: // TOP
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::RETURNPIC:
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ {
-+ std::string portName = port == NULL ? "timer" : port->portName;
-+ CLog::Log(LOGWARNING, "COutput::%s - signal: %d form port: %s not handled for state: %d", __FUNCTION__, signal, portName.c_str(), m_state);
-+ }
-+ return;
-+
-+ case O_TOP_ERROR:
-+ break;
-+
-+ case O_TOP_UNCONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::INIT:
-+ CVdpauConfig *data;
-+ data = (CVdpauConfig*)msg->data;
-+ if (data)
-+ {
-+ m_config = *data;
-+ }
-+ Init();
-+ Message *reply;
-+ if (m_mixer.m_controlPort.SendOutMessageSync(CMixerControlProtocol::INIT,
-+ &reply, 1000, &m_config, sizeof(m_config)))
-+ {
-+ if (reply->signal != CMixerControlProtocol::ACC)
-+ m_vdpError = true;
-+ reply->Release();
-+ }
-+
-+ // set initial number of
-+ m_bufferPool.numOutputSurfaces = 4;
-+ EnsureBufferPool();
-+ if (!m_vdpError)
-+ {
-+ m_state = O_TOP_CONFIGURED_IDLE;
-+ msg->Reply(COutputControlProtocol::ACC);
-+ }
-+ else
-+ {
-+ m_state = O_TOP_ERROR;
-+ msg->Reply(COutputControlProtocol::ERROR);
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ Flush();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ Flush();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::NEWFRAME:
-+ CVdpauDecodedPicture *frame;
-+ frame = (CVdpauDecodedPicture*)msg->data;
-+ if (frame)
-+ {
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::FRAME,
-+ frame,sizeof(CVdpauDecodedPicture));
-+ }
-+ return;
-+ case COutputDataProtocol::RETURNPIC:
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ m_controlPort.SendInMessage(COutputControlProtocol::STATS);
-+ m_state = O_TOP_CONFIGURED_WORK;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_mixer.m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case CMixerDataProtocol::PICTURE:
-+ CVdpauProcessedPicture *pic;
-+ pic = (CVdpauProcessedPicture*)msg->data;
-+ m_bufferPool.processedPics.push(*pic);
-+ m_state = O_TOP_CONFIGURED_WORK;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_IDLE:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+// uint16_t decoded, processed, render;
-+// m_config.stats->Get(decoded, processed, render);
-+// CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WORK:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (HasWork())
-+ {
-+ CVdpauRenderPicture *pic;
-+ pic = ProcessMixerPicture();
-+ if (pic)
-+ {
-+ m_config.stats->DecProcessed();
-+ m_config.stats->IncRender();
-+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic));
-+ }
-+ m_extTimeout = 1;
-+ }
-+ else
-+ {
-+ m_state = O_TOP_CONFIGURED_IDLE;
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ default: // we are in no state, should not happen
-+ CLog::Log(LOGERROR, "COutput::%s - no valid state: %d", __FUNCTION__, m_state);
-+ return;
-+ }
-+ } // for
-+}
-+
-+void COutput::Process()
-+{
-+ Message *msg;
-+ Protocol *port;
-+ bool gotMsg;
-+
-+ m_state = O_TOP_UNCONFIGURED;
-+ m_extTimeout = 1000;
-+ m_bStateMachineSelfTrigger = false;
-+
-+ while (!m_bStop)
-+ {
-+ gotMsg = false;
-+
-+ if (m_bStateMachineSelfTrigger)
-+ {
-+ m_bStateMachineSelfTrigger = false;
-+ // self trigger state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+ // check control port
-+ else if (m_controlPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_controlPort;
-+ }
-+ // check data port
-+ else if (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_dataPort;
-+ }
-+ // check mixer data port
-+ else if (m_mixer.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_mixer.m_dataPort;
-+ }
-+ if (gotMsg)
-+ {
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+
-+ // wait for message
-+ else if (m_outMsgEvent.WaitMSec(m_extTimeout))
-+ {
-+ continue;
-+ }
-+ // time out
-+ else
-+ {
-+ msg = m_controlPort.GetMessage();
-+ msg->signal = COutputControlProtocol::TIMEOUT;
-+ port = 0;
-+ // signal timeout to state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ }
-+ }
-+ Flush();
-+ Uninit();
-+}
-+
-+bool COutput::Init()
-+{
-+ if (!CreateGlxContext())
-+ return false;
-+
-+ if (!GLInit())
-+ return false;
-+
-+ m_mixer.Start();
-+ m_vdpError = false;
-+
-+ return true;
-+}
-+
-+bool COutput::Uninit()
-+{
-+ m_mixer.Dispose();
-+ GLUnmapSurfaces();
-+ GLUnbindPixmaps();
-+ ReleaseBufferPool();
-+ DestroyGlxContext();
-+ return true;
-+}
-+
-+void COutput::Flush()
-+{
-+ Message *reply;
-+ if (m_mixer.m_controlPort.SendOutMessageSync(CMixerControlProtocol::FLUSH,
-+ &reply,
-+ 2000))
-+ {
-+ reply->Release();
-+ }
-+ else
-+ CLog::Log(LOGERROR, "Coutput::%s - failed to flush mixer", __FUNCTION__);
-+
-+ Message *msg;
-+ while (m_mixer.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == CMixerDataProtocol::PICTURE)
-+ {
-+ CVdpauProcessedPicture pic = *(CVdpauProcessedPicture*)msg->data;
-+ if (pic.DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ }
-+ msg->Release();
-+ }
-+
-+ while (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::NEWFRAME)
-+ {
-+ CVdpauDecodedPicture pic = *(CVdpauDecodedPicture*)msg->data;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ else if (msg->signal == COutputDataProtocol::RETURNPIC)
-+ {
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ msg->Release();
-+ }
-+
-+ while (m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
-+ {
-+ CVdpauRenderPicture *pic;
-+ pic = *((CVdpauRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ }
-+
-+ // reset used render flag which was cleared on mixer flush
-+ std::deque::iterator it;
-+ for (it = m_bufferPool.usedRenderPics.begin(); it != m_bufferPool.usedRenderPics.end(); ++it)
-+ {
-+ if ((*it)->DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ std::map::iterator it2;
-+ it2 = m_bufferPool.glVideoSurfaceMap.find((*it)->sourceIdx);
-+ if (it2 == m_bufferPool.glVideoSurfaceMap.end())
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::Flush - gl surface not found");
-+ continue;
-+ }
-+ vdpau_render_state *render = it2->second.sourceVuv;
-+ if (render)
-+ render->state |= FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ }
-+}
-+
-+bool COutput::HasWork()
-+{
-+ if (m_config.usePixmaps)
-+ {
-+ if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0)
-+ return true;
-+ if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty())
-+ return true;
-+ return false;
-+ }
-+ else
-+ {
-+ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
-+ return true;
-+ return false;
-+ }
-+}
-+
-+CVdpauRenderPicture* COutput::ProcessMixerPicture()
-+{
-+ CVdpauRenderPicture *retPic = 0;
-+
-+ if (m_config.usePixmaps)
-+ {
-+ if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0)
-+ {
-+ unsigned int i = FindFreePixmap();
-+ VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[i];
-+ pixmap->used = true;
-+ CVdpauProcessedPicture pic = m_bufferPool.processedPics.front();
-+ m_bufferPool.processedPics.pop();
-+ pixmap->surface = pic.outputSurface;
-+ pixmap->DVDPic = pic.DVDPic;
-+ pixmap->id = i;
-+ m_bufferPool.notVisiblePixmaps.push_back(pixmap);
-+ VdpStatus vdp_st;
-+ m_config.vdpProcs.vdp_presentation_queue_display(pixmap->vdp_flip_queue,
-+ pixmap->surface,0,0,0);
-+ }
-+ if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ VdpStatus vdp_st;
-+ VdpTime time;
-+ VdpPresentationQueueStatus status;
-+ VdpauBufferPool::Pixmaps *pixmap = m_bufferPool.notVisiblePixmaps.front();
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_query_surface_status(
-+ pixmap->vdp_flip_queue, pixmap->surface, &status, &time);
-+
-+ if (vdp_st == VDP_STATUS_OK && status == VDP_PRESENTATION_QUEUE_STATUS_VISIBLE)
-+ {
-+ retPic = m_bufferPool.freeRenderPics.front();
-+ m_bufferPool.freeRenderPics.pop_front();
-+ m_bufferPool.usedRenderPics.push_back(retPic);
-+ retPic->sourceIdx = pixmap->id;
-+ retPic->DVDPic = pixmap->DVDPic;
-+ retPic->valid = true;
-+ retPic->texture[0] = pixmap->texture;
-+ retPic->crop = CRect(0,0,0,0);
-+ m_bufferPool.notVisiblePixmaps.pop_front();
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &pixmap->surface, sizeof(pixmap->surface));
-+ }
-+ }
-+ } // pixmap
-+ else if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ retPic = m_bufferPool.freeRenderPics.front();
-+ m_bufferPool.freeRenderPics.pop_front();
-+ m_bufferPool.usedRenderPics.push_back(retPic);
-+ CVdpauProcessedPicture procPic = m_bufferPool.processedPics.front();
-+ m_bufferPool.processedPics.pop();
-+
-+ retPic->DVDPic = procPic.DVDPic;
-+ retPic->valid = true;
-+ if (retPic->DVDPic.format == DVDVideoPicture::FMT_VDPAU)
-+ {
-+ m_config.useInteropYuv = false;
-+ m_bufferPool.numOutputSurfaces = NUM_RENDER_PICS;
-+ EnsureBufferPool();
-+ GLMapSurfaces();
-+ retPic->sourceIdx = procPic.outputSurface;
-+ retPic->texture[0] = m_bufferPool.glOutputSurfaceMap[procPic.outputSurface].texture[0];
-+ retPic->crop = CRect(0,0,0,0);
-+ }
-+ else
-+ {
-+ m_config.useInteropYuv = true;
-+ GLMapSurfaces();
-+ retPic->sourceIdx = procPic.render->surface;
-+ for (unsigned int i=0; i<4; ++i)
-+ retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.render->surface].texture[i];
-+ retPic->texWidth = m_config.surfaceWidth;
-+ retPic->texHeight = m_config.surfaceHeight;
-+ retPic->crop.x1 = 0;
-+ retPic->crop.y1 = 0;
-+ retPic->crop.x2 = m_config.surfaceWidth - m_config.vidWidth;
-+ retPic->crop.y2 = m_config.surfaceHeight - m_config.vidHeight;
-+ }
-+ }
-+ return retPic;
-+}
-+
-+void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic)
-+{
-+ std::deque::iterator it;
-+ it = std::find(m_bufferPool.usedRenderPics.begin(), m_bufferPool.usedRenderPics.end(), pic);
-+ if (it == m_bufferPool.usedRenderPics.end())
-+ {
-+ CLog::Log(LOGWARNING, "COutput::ProcessReturnPicture - pic not found");
-+ return;
-+ }
-+ m_bufferPool.usedRenderPics.erase(it);
-+ m_bufferPool.freeRenderPics.push_back(pic);
-+ if (!pic->valid)
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::%s - return of invalid render pic", __FUNCTION__);
-+ return;
-+ }
-+
-+ if (m_config.usePixmaps)
-+ {
-+ m_bufferPool.pixmaps[pic->sourceIdx].used = false;
-+ return;
-+ }
-+ else if (pic->DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ {
-+ std::map::iterator it;
-+ it = m_bufferPool.glVideoSurfaceMap.find(pic->sourceIdx);
-+ if (it == m_bufferPool.glVideoSurfaceMap.end())
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
-+ return;
-+ }
-+ vdpau_render_state *render = it->second.sourceVuv;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ render->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-+ }
-+ else if (pic->DVDPic.format == DVDVideoPicture::FMT_VDPAU)
-+ {
-+ std::map::iterator it;
-+ it = m_bufferPool.glOutputSurfaceMap.find(pic->sourceIdx);
-+ if (it == m_bufferPool.glOutputSurfaceMap.end())
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
-+ return;
-+ }
-+ VdpOutputSurface outSurf = it->second.sourceRgb;
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &outSurf, sizeof(outSurf));
-+ }
-+}
-+
-+int COutput::FindFreePixmap()
-+{
-+ // find free pixmap
-+ unsigned int i;
-+ for (i = 0; i < m_bufferPool.pixmaps.size(); ++i)
-+ {
-+ if (!m_bufferPool.pixmaps[i].used)
-+ break;
-+ }
-+ if (i == m_bufferPool.pixmaps.size())
-+ return -1;
-+ else
-+ return i;
-+}
-+
-+bool COutput::EnsureBufferPool()
-+{
-+ VdpStatus vdp_st;
-+
-+ // Creation of outputSurfaces
-+ VdpOutputSurface outputSurface;
-+ for (int i = m_bufferPool.outputSurfaces.size(); i < m_bufferPool.numOutputSurfaces; i++)
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_create(m_config.vdpDevice,
-+ VDP_RGBA_FORMAT_B8G8R8A8,
-+ m_config.outWidth,
-+ m_config.outHeight,
-+ &outputSurface);
-+ if (CheckStatus(vdp_st, __LINE__))
-+ return false;
-+ m_bufferPool.outputSurfaces.push_back(outputSurface);
-+
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER,
-+ &outputSurface,
-+ sizeof(VdpOutputSurface));
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput::InitBufferPool - Output Surface created");
-+ }
-+
-+
-+ if (m_config.usePixmaps && m_bufferPool.pixmaps.empty())
-+ {
-+ // create pixmpas
-+ VdpauBufferPool::Pixmaps pixmap;
-+ int numPixmaps = NUM_RENDER_PICS;
-+ for (unsigned int i = 0; i < numPixmaps; i++)
-+ {
-+ pixmap.pixmap = None;
-+ pixmap.glPixmap = None;
-+ pixmap.vdp_flip_queue = VDP_INVALID_HANDLE;
-+ pixmap.vdp_flip_target = VDP_INVALID_HANDLE;
-+ MakePixmap(pixmap);
-+ glXMakeCurrent(m_Display, None, NULL);
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_create_x11(m_config.vdpDevice,
-+ pixmap.pixmap, //x_window,
-+ &pixmap.vdp_flip_target);
-+
-+ CheckStatus(vdp_st, __LINE__);
-+
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_create(m_config.vdpDevice,
-+ pixmap.vdp_flip_target,
-+ &pixmap.vdp_flip_queue);
-+ CheckStatus(vdp_st, __LINE__);
-+ glXMakeCurrent(m_Display, m_glPixmap, m_glContext);
-+
-+ pixmap.id = i;
-+ pixmap.used = false;
-+ m_bufferPool.pixmaps.push_back(pixmap);
-+ }
-+ GLBindPixmaps();
-+ }
-+
-+ return true;
-+}
-+
-+void COutput::ReleaseBufferPool()
-+{
-+ VdpStatus vdp_st;
-+
-+ CSingleLock lock(m_bufferPool.renderPicSec);
-+
-+ if (m_config.usePixmaps)
-+ {
-+ for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); ++i)
-+ {
-+ if (m_bufferPool.pixmaps[i].vdp_flip_queue != VDP_INVALID_HANDLE)
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+ if (m_bufferPool.pixmaps[i].vdp_flip_target != VDP_INVALID_HANDLE)
-+ {
-+ vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+ if (m_bufferPool.pixmaps[i].glPixmap)
-+ {
-+ glXDestroyPixmap(m_Display, m_bufferPool.pixmaps[i].glPixmap);
-+ }
-+ if (m_bufferPool.pixmaps[i].pixmap)
-+ {
-+ XFreePixmap(m_Display, m_bufferPool.pixmaps[i].pixmap);
-+ }
-+ }
-+ m_bufferPool.pixmaps.clear();
-+ }
-+
-+ // release all output surfaces
-+ for (unsigned int i = 0; i < m_bufferPool.outputSurfaces.size(); ++i)
-+ {
-+ if (m_bufferPool.outputSurfaces[i] == VDP_INVALID_HANDLE)
-+ continue;
-+ vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]);
-+ CheckStatus(vdp_st, __LINE__);
-+ }
-+ m_bufferPool.outputSurfaces.clear();
-+
-+ // invalidate all used render pictures
-+ for (unsigned int i = 0; i < m_bufferPool.usedRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.usedRenderPics[i]->valid = false;
-+ }
-+}
-+
-+void COutput::InitMixer()
-+{
-+ for (unsigned int i = 0; i < m_bufferPool.outputSurfaces.size(); ++i)
-+ {
-+ m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER,
-+ &m_bufferPool.outputSurfaces[i],
-+ sizeof(VdpOutputSurface));
-+ }
-+}
-+
-+bool COutput::MakePixmap(VdpauBufferPool::Pixmaps &pixmap)
-+{
-+ CLog::Log(LOGNOTICE,"Creating %ix%i pixmap", m_config.outWidth, m_config.outHeight);
-+
-+ // Get our window attribs.
-+ XWindowAttributes wndattribs;
-+ XGetWindowAttributes(m_Display, DefaultRootWindow(m_Display), &wndattribs);
-+
-+ pixmap.pixmap = XCreatePixmap(m_Display,
-+ DefaultRootWindow(m_Display),
-+ m_config.outWidth,
-+ m_config.outHeight,
-+ wndattribs.depth);
-+ if (!pixmap.pixmap)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COUtput::MakePixmap - GLX Error: MakePixmap: Unable to create XPixmap");
-+ return false;
-+ }
-+
-+// XGCValues values = {};
-+// GC xgc;
-+// values.foreground = BlackPixel (m_Display, DefaultScreen (m_Display));
-+// xgc = XCreateGC(m_Display, pixmap.pixmap, GCForeground, &values);
-+// XFillRectangle(m_Display, pixmap.pixmap, xgc, 0, 0, m_config.outWidth, m_config.outHeight);
-+// XFreeGC(m_Display, xgc);
-+
-+ if(!MakePixmapGL(pixmap))
-+ return false;
-+
-+ return true;
-+}
-+
-+bool COutput::MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap)
-+{
-+ int num=0;
-+ int fbConfigIndex = 0;
-+
-+ int doubleVisAttributes[] = {
-+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
-+ GLX_RED_SIZE, 8,
-+ GLX_GREEN_SIZE, 8,
-+ GLX_BLUE_SIZE, 8,
-+ GLX_ALPHA_SIZE, 8,
-+ GLX_DEPTH_SIZE, 8,
-+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
-+ GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
-+ GLX_DOUBLEBUFFER, False,
-+ GLX_Y_INVERTED_EXT, True,
-+ GLX_X_RENDERABLE, True,
-+ None
-+ };
-+
-+ int pixmapAttribs[] = {
-+ GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
-+ GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
-+ None
-+ };
-+
-+ GLXFBConfig *fbConfigs;
-+ fbConfigs = glXChooseFBConfig(m_Display, DefaultScreen(m_Display), doubleVisAttributes, &num);
-+ if (fbConfigs==NULL)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - No compatible framebuffers found");
-+ return false;
-+ }
-+ fbConfigIndex = 0;
-+
-+ pixmap.glPixmap = glXCreatePixmap(m_Display, fbConfigs[fbConfigIndex], pixmap.pixmap, pixmapAttribs);
-+
-+ if (!pixmap.glPixmap)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - Could not create Pixmap");
-+ XFree(fbConfigs);
-+ return false;
-+ }
-+ XFree(fbConfigs);
-+ return true;
-+}
-+
-+bool COutput::GLInit()
-+{
-+ glXBindTexImageEXT = NULL;
-+ glXReleaseTexImageEXT = NULL;
-+#ifdef GL_NV_vdpau_interop
-+ glVDPAUInitNV = NULL;
-+ glVDPAUFiniNV = NULL;
-+ glVDPAURegisterOutputSurfaceNV = NULL;
-+ glVDPAURegisterVideoSurfaceNV = NULL;
-+ glVDPAUIsSurfaceNV = NULL;
-+ glVDPAUUnregisterSurfaceNV = NULL;
-+ glVDPAUSurfaceAccessNV = NULL;
-+ glVDPAUMapSurfacesNV = NULL;
-+ glVDPAUUnmapSurfacesNV = NULL;
-+ glVDPAUGetSurfaceivNV = NULL;
-+#endif
-+
-+ m_config.usePixmaps = !g_guiSettings.GetBool("videoplayer.usevdpauinteroprgb");
-+
-+#ifdef GL_NV_vdpau_interop
-+ if (glewIsSupported("GL_NV_vdpau_interop"))
-+ {
-+ if (!glVDPAUInitNV)
-+ glVDPAUInitNV = (PFNGLVDPAUINITNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUInitNV");
-+ if (!glVDPAUFiniNV)
-+ glVDPAUFiniNV = (PFNGLVDPAUFININVPROC)glXGetProcAddress((GLubyte *) "glVDPAUFiniNV");
-+ if (!glVDPAURegisterOutputSurfaceNV)
-+ glVDPAURegisterOutputSurfaceNV = (PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterOutputSurfaceNV");
-+ if (!glVDPAURegisterVideoSurfaceNV)
-+ glVDPAURegisterVideoSurfaceNV = (PFNGLVDPAUREGISTERVIDEOSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAURegisterVideoSurfaceNV");
-+ if (!glVDPAUIsSurfaceNV)
-+ glVDPAUIsSurfaceNV = (PFNGLVDPAUISSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUIsSurfaceNV");
-+ if (!glVDPAUUnregisterSurfaceNV)
-+ glVDPAUUnregisterSurfaceNV = (PFNGLVDPAUUNREGISTERSURFACENVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnregisterSurfaceNV");
-+ if (!glVDPAUSurfaceAccessNV)
-+ glVDPAUSurfaceAccessNV = (PFNGLVDPAUSURFACEACCESSNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUSurfaceAccessNV");
-+ if (!glVDPAUMapSurfacesNV)
-+ glVDPAUMapSurfacesNV = (PFNGLVDPAUMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUMapSurfacesNV");
-+ if (!glVDPAUUnmapSurfacesNV)
-+ glVDPAUUnmapSurfacesNV = (PFNGLVDPAUUNMAPSURFACESNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUUnmapSurfacesNV");
-+ if (!glVDPAUGetSurfaceivNV)
-+ glVDPAUGetSurfaceivNV = (PFNGLVDPAUGETSURFACEIVNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUGetSurfaceivNV");
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput GL interop supported");
-+ }
-+ else
-+#endif
-+ {
-+ m_config.usePixmaps = true;
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
-+ }
-+ if (!glXBindTexImageEXT)
-+ glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT");
-+ if (!glXReleaseTexImageEXT)
-+ glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT");
-+
-+#ifdef GL_NV_vdpau_interop
-+ if (!m_config.usePixmaps)
-+ {
-+ while (glGetError() != GL_NO_ERROR);
-+ glVDPAUInitNV(reinterpret_cast(m_config.vdpDevice), reinterpret_cast(m_config.vdpProcs.vdp_get_proc_address));
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed");
-+ m_vdpError = true;
-+ return false;
-+ }
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized");
-+ }
-+#endif
-+ return true;
-+}
-+
-+void COutput::GLMapSurfaces()
-+{
-+#ifdef GL_NV_vdpau_interop
-+ if (m_config.usePixmaps)
-+ return;
-+
-+ if (m_config.useInteropYuv)
-+ {
-+ VdpauBufferPool::GLVideoSurface glSurface;
-+ if (m_config.videoSurfaces->size() != m_bufferPool.glVideoSurfaceMap.size())
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ for (int i = 0; i < m_config.videoSurfaces->size(); i++)
-+ {
-+ if ((*m_config.videoSurfaces)[i]->surface == VDP_INVALID_HANDLE)
-+ continue;
-+
-+ if (m_bufferPool.glVideoSurfaceMap.find((*m_config.videoSurfaces)[i]->surface) == m_bufferPool.glVideoSurfaceMap.end())
-+ {
-+ glSurface.sourceVuv = (*m_config.videoSurfaces)[i];
-+ while (glGetError() != GL_NO_ERROR) ;
-+ glGenTextures(4, glSurface.texture);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error creating texture");
-+ m_vdpError = true;
-+ }
-+ glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast((*m_config.videoSurfaces)[i]->surface),
-+ GL_TEXTURE_2D, 4, glSurface.texture);
-+
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error register video surface");
-+ m_vdpError = true;
-+ }
-+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
-+ m_vdpError = true;
-+ }
-+ glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
-+ m_vdpError = true;
-+ }
-+ m_bufferPool.glVideoSurfaceMap[(*m_config.videoSurfaces)[i]->surface] = glSurface;
-+ if (m_vdpError)
-+ return;
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface");
-+ }
-+ }
-+ }
-+ }
-+ else
-+ {
-+ if (m_bufferPool.glOutputSurfaceMap.size() != m_bufferPool.numOutputSurfaces)
-+ {
-+ VdpauBufferPool::GLVideoSurface glSurface;
-+ for (int i=m_bufferPool.glOutputSurfaceMap.size(); i(m_bufferPool.outputSurfaces[i]),
-+ GL_TEXTURE_2D, 1, glSurface.texture);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error register output surface");
-+ m_vdpError = true;
-+ }
-+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
-+ m_vdpError = true;
-+ }
-+ glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
-+ if (glGetError() != GL_NO_ERROR)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
-+ m_vdpError = true;
-+ }
-+ m_bufferPool.glOutputSurfaceMap[m_bufferPool.outputSurfaces[i]] = glSurface;
-+ if (m_vdpError)
-+ return;
-+ }
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput registered output surfaces");
-+ }
-+ }
-+#endif
-+}
-+
-+void COutput::GLUnmapSurfaces()
-+{
-+#ifdef GL_NV_vdpau_interop
-+ if (m_config.usePixmaps)
-+ return;
-+
-+ { CSingleLock lock(*m_config.videoSurfaceSec);
-+ std::map::iterator it;
-+ for (it = m_bufferPool.glVideoSurfaceMap.begin(); it != m_bufferPool.glVideoSurfaceMap.end(); ++it)
-+ {
-+ glVDPAUUnregisterSurfaceNV(it->second.glVdpauSurface);
-+ glDeleteTextures(4, it->second.texture);
-+ }
-+ m_bufferPool.glVideoSurfaceMap.clear();
-+ }
-+
-+ std::map::iterator it;
-+ for (it = m_bufferPool.glOutputSurfaceMap.begin(); it != m_bufferPool.glOutputSurfaceMap.end(); ++it)
-+ {
-+ glVDPAUUnregisterSurfaceNV(it->second.glVdpauSurface);
-+ glDeleteTextures(1, it->second.texture);
-+ }
-+ m_bufferPool.glOutputSurfaceMap.clear();
-+
-+ glVDPAUFiniNV();
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop finished");
-+
-+#endif
-+}
-+
-+void COutput::GLBindPixmaps()
-+{
-+ if (!m_config.usePixmaps)
-+ return;
-+
-+ for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++)
-+ {
-+ // create texture
-+ glGenTextures(1, &m_bufferPool.pixmaps[i].texture);
-+
-+ //bind texture
-+ glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture);
-+
-+ // bind pixmap
-+ glXBindTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT, NULL);
-+
-+ glBindTexture(GL_TEXTURE_2D, 0);
-+ }
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: bound pixmaps");
-+}
-+
-+void COutput::GLUnbindPixmaps()
-+{
-+ if (!m_config.usePixmaps)
-+ return;
-+
-+ for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++)
-+ {
-+ // create texture
-+ if (!glIsTexture(m_bufferPool.pixmaps[i].texture))
-+ continue;
-+
-+ //bind texture
-+ glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture);
-+
-+ // release pixmap
-+ glXReleaseTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT);
-+
-+ glBindTexture(GL_TEXTURE_2D, 0);
-+
-+ glDeleteTextures(1, &m_bufferPool.pixmaps[i].texture);
-+ }
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput: unbound pixmaps");
-+}
-+
-+bool COutput::CheckStatus(VdpStatus vdp_st, int line)
-+{
-+ if (vdp_st != VDP_STATUS_OK)
-+ {
-+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
-+ m_vdpError = true;
-+ return true;
-+ }
-+ return false;
-+}
-+
-+bool COutput::CreateGlxContext()
-+{
-+ GLXContext glContext;
-+ Window window;
-+
-+ m_Display = g_Windowing.GetDisplay();
-+ glContext = g_Windowing.GetGlxContext();
-+ m_Window = g_Windowing.GetWmWindow();
-+
-+ // Get our window attribs.
-+ XWindowAttributes wndattribs;
-+ XGetWindowAttributes(m_Display, m_Window, &wndattribs);
-+
-+ // Get visual Info
-+ XVisualInfo visInfo;
-+ visInfo.visualid = wndattribs.visual->visualid;
-+ int nvisuals = 0;
-+ XVisualInfo* visuals = XGetVisualInfo(m_Display, VisualIDMask, &visInfo, &nvisuals);
-+ if (nvisuals != 1)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::CreateGlxContext - could not find visual");
-+ return false;
-+ }
-+ visInfo = visuals[0];
-+ XFree(visuals);
-+
-+ m_pixmap = XCreatePixmap(m_Display,
-+ DefaultRootWindow(m_Display),
-+ 192,
-+ 108,
-+ visInfo.depth);
-+ if (!m_pixmap)
-+ {
-+ CLog::Log(LOGERROR, "VDPAU::COutput::CreateGlxContext - Unable to create XPixmap");
-+ return false;
-+ }
-+
-+ // create gl pixmap
-+ m_glPixmap = glXCreateGLXPixmap(m_Display, &visInfo, m_pixmap);
-+
-+ if (!m_glPixmap)
-+ {
-+ CLog::Log(LOGINFO, "VDPAU::COutput::CreateGlxContext - Could not create glPixmap");
-+ return false;
-+ }
-+
-+ m_glContext = glXCreateContext(m_Display, &visInfo, glContext, True);
-+
-+ if (!glXMakeCurrent(m_Display, m_glPixmap, m_glContext))
-+ {
-+ CLog::Log(LOGINFO, "VDPAU::COutput::CreateGlxContext - Could not make Pixmap current");
-+ return false;
-+ }
-+
-+ CLog::Log(LOGNOTICE, "VDPAU::COutput::CreateGlxContext - created context");
-+ return true;
-+}
-+
-+bool COutput::DestroyGlxContext()
-+{
-+ if (m_glContext)
-+ {
-+ glXMakeCurrent(m_Display, None, NULL);
-+ glXDestroyContext(m_Display, m_glContext);
-+ }
-+ m_glContext = 0;
-+
-+ if (m_glPixmap)
-+ glXDestroyPixmap(m_Display, m_glPixmap);
-+ m_glPixmap = 0;
-+
-+ if (m_pixmap)
-+ XFreePixmap(m_Display, m_pixmap);
-+ m_pixmap = 0;
-+
-+ return true;
-+}
-+
-+
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h 2012-05-14 14:15:12.131220406 +0200
-@@ -1,4 +1,3 @@
--
- #pragma once
- /*
- * Copyright (C) 2005-2009 Team XBMC
-@@ -21,6 +20,24 @@
- *
- */
-
-+/**
-+ * design goals:
-+ * - improve performance
-+ * max out hw resources: e.g. make 1080p60 play on ION2
-+ * allow advanced de-interlacing on ION
-+ *
-+ * - add vdpau/opengl interop
-+ *
-+ * - remove tight dependency to render thread
-+ * prior design needed to hijack render thread in order to do
-+ * gl interop functions. In particular this was a problem for
-+ * init and clear down. Introduction of GL_NV_vdpau_interop
-+ * increased the need to be independent from render thread
-+ *
-+ * - move to an actor based design in order to reduce the number
-+ * of locks needed.
-+ */
-+
- #include "DllAvUtil.h"
- #include "DVDVideoCodec.h"
- #include "DVDVideoCodecFFmpeg.h"
-@@ -37,118 +54,31 @@
- #include "settings/VideoSettings.h"
- #include "guilib/DispResource.h"
- #include "threads/Event.h"
--namespace Surface { class CSurface; }
--
--#define NUM_OUTPUT_SURFACES 4
--#define NUM_VIDEO_SURFACES_MPEG2 10 // (1 frame being decoded, 2 reference)
--#define NUM_VIDEO_SURFACES_H264 32 // (1 frame being decoded, up to 16 references)
--#define NUM_VIDEO_SURFACES_VC1 10 // (same as MPEG-2)
--#define NUM_OUTPUT_SURFACES_FOR_FULLHD 2
--#define FULLHD_WIDTH 1920
--
--class CVDPAU
-- : public CDVDVideoCodecFFmpeg::IHardwareDecoder
-- , public IDispResource
--{
--public:
--
-- struct pictureAge
-- {
-- int b_age;
-- int ip_age[2];
-- };
--
-- struct Desc
-- {
-- const char *name;
-- uint32_t id;
-- uint32_t aux; /* optional extra parameter... */
-- };
-+#include "threads/Thread.h"
-+#include "utils/ActorProtocol.h"
-
-- CVDPAU();
-- virtual ~CVDPAU();
--
-- virtual bool Open (AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces = 0);
-- virtual int Decode (AVCodecContext* avctx, AVFrame* frame);
-- virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture);
-- virtual void Reset();
-- virtual void Close();
--
-- virtual int Check(AVCodecContext* avctx);
--
-- virtual const std::string Name() { return "vdpau"; }
--
-- bool MakePixmap(int width, int height);
-- bool MakePixmapGL();
--
-- void ReleasePixmap();
-- void BindPixmap();
--
-- PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT;
-- PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT;
-- GLXPixmap m_glPixmap;
-- Pixmap m_Pixmap;
-+using namespace Actor;
-
-- static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic);
-- static void FFDrawSlice(struct AVCodecContext *s,
-- const AVFrame *src, int offset[4],
-- int y, int type, int height);
-- static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
-
-- void Present();
-- bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames);
-- void SpewHardwareAvailable();
-- void InitCSCMatrix(int Height);
-- bool CheckStatus(VdpStatus vdp_st, int line);
-- bool IsSurfaceValid(vdpau_render_state *render);
--
-- void CheckFeatures();
-- void SetColor();
-- void SetNoiseReduction();
-- void SetSharpness();
-- void SetDeinterlacing();
-- void SetHWUpscaling();
-+#define FULLHD_WIDTH 1920
-+#define MAX_PIC_Q_LENGTH 20 //for non-interop_yuv this controls the max length of the decoded pic to render completion Q
-
-- pictureAge picAge;
-- vdpau_render_state *past[2], *current, *future;
-- int tmpDeintMode, tmpDeintGUI, tmpDeint;
-- float tmpNoiseReduction, tmpSharpness;
-- float tmpBrightness, tmpContrast;
-- int OutWidth, OutHeight;
-- bool upScale;
-- std::queue m_DVDVideoPics;
--
-- static inline void ClearUsedForRender(vdpau_render_state **st)
-- {
-- if (*st) {
-- (*st)->state &= ~FF_VDPAU_STATE_USED_FOR_RENDER;
-- *st = NULL;
-- }
-- }
-+namespace VDPAU
-+{
-
-- VdpProcamp m_Procamp;
-- VdpCSCMatrix m_CSCMatrix;
-- VdpDevice HasDevice() { return vdp_device != VDP_INVALID_HANDLE; };
-- VdpChromaType vdp_chroma_type;
-+/**
-+ * VDPAU interface to driver
-+ */
-
-+struct VDPAU_procs
-+{
-+ VdpGetProcAddress * vdp_get_proc_address;
-+ VdpDeviceDestroy * vdp_device_destroy;
-
-- // protected:
-- void InitVDPAUProcs();
-- void FiniVDPAUProcs();
-- void FiniVDPAUOutput();
-- bool ConfigOutputMethod(AVCodecContext *avctx, AVFrame *pFrame);
-- bool FiniOutputMethod();
--
-- VdpDevice vdp_device;
-- VdpGetProcAddress * vdp_get_proc_address;
-- VdpPresentationQueueTarget vdp_flip_target;
-- VdpPresentationQueue vdp_flip_queue;
-- VdpDeviceDestroy * vdp_device_destroy;
--
-- VdpVideoSurfaceCreate * vdp_video_surface_create;
-- VdpVideoSurfaceDestroy * vdp_video_surface_destroy;
-- VdpVideoSurfacePutBitsYCbCr * vdp_video_surface_put_bits_y_cb_cr;
-- VdpVideoSurfaceGetBitsYCbCr * vdp_video_surface_get_bits_y_cb_cr;
-+ VdpVideoSurfaceCreate * vdp_video_surface_create;
-+ VdpVideoSurfaceDestroy * vdp_video_surface_destroy;
-+ VdpVideoSurfacePutBitsYCbCr * vdp_video_surface_put_bits_y_cb_cr;
-+ VdpVideoSurfaceGetBitsYCbCr * vdp_video_surface_get_bits_y_cb_cr;
-
- VdpOutputSurfacePutBitsYCbCr * vdp_output_surface_put_bits_y_cb_cr;
- VdpOutputSurfacePutBitsNative * vdp_output_surface_put_bits_native;
-@@ -158,15 +88,15 @@
- VdpOutputSurfaceRenderOutputSurface * vdp_output_surface_render_output_surface;
- VdpOutputSurfacePutBitsIndexed * vdp_output_surface_put_bits_indexed;
-
-- VdpVideoMixerCreate * vdp_video_mixer_create;
-- VdpVideoMixerSetFeatureEnables * vdp_video_mixer_set_feature_enables;
-- VdpVideoMixerQueryParameterSupport * vdp_video_mixer_query_parameter_support;
-- VdpVideoMixerQueryFeatureSupport * vdp_video_mixer_query_feature_support;
-- VdpVideoMixerDestroy * vdp_video_mixer_destroy;
-- VdpVideoMixerRender * vdp_video_mixer_render;
-- VdpVideoMixerSetAttributeValues * vdp_video_mixer_set_attribute_values;
-+ VdpVideoMixerCreate * vdp_video_mixer_create;
-+ VdpVideoMixerSetFeatureEnables * vdp_video_mixer_set_feature_enables;
-+ VdpVideoMixerQueryParameterSupport * vdp_video_mixer_query_parameter_support;
-+ VdpVideoMixerQueryFeatureSupport * vdp_video_mixer_query_feature_support;
-+ VdpVideoMixerDestroy * vdp_video_mixer_destroy;
-+ VdpVideoMixerRender * vdp_video_mixer_render;
-+ VdpVideoMixerSetAttributeValues * vdp_video_mixer_set_attribute_values;
-
-- VdpGenerateCSCMatrix * vdp_generate_csc_matrix;
-+ VdpGenerateCSCMatrix * vdp_generate_csc_matrix;
-
- VdpPresentationQueueTargetDestroy * vdp_presentation_queue_target_destroy;
- VdpPresentationQueueCreate * vdp_presentation_queue_create;
-@@ -179,64 +109,467 @@
-
- VdpGetErrorString * vdp_get_error_string;
-
-- VdpDecoderCreate * vdp_decoder_create;
-- VdpDecoderDestroy * vdp_decoder_destroy;
-- VdpDecoderRender * vdp_decoder_render;
-- VdpDecoderQueryCapabilities * vdp_decoder_query_caps;
-+ VdpDecoderCreate * vdp_decoder_create;
-+ VdpDecoderDestroy * vdp_decoder_destroy;
-+ VdpDecoderRender * vdp_decoder_render;
-+ VdpDecoderQueryCapabilities * vdp_decoder_query_caps;
-
- VdpPreemptionCallbackRegister * vdp_preemption_callback_register;
-
-- VdpOutputSurface outputSurfaces[NUM_OUTPUT_SURFACES];
-- VdpOutputSurface outputSurface;
-- VdpOutputSurface presentSurface;
--
-- VdpDecoder decoder;
-- VdpVideoMixer videoMixer;
-- VdpRect outRect;
-- VdpRect outRectVid;
-+};
-
-- static void* dl_handle;
-- VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address);
-- VdpStatus (*dl_vdp_get_proc_address)(VdpDevice device, VdpFuncId function_id, void** function_pointer);
-- VdpStatus (*dl_vdp_preemption_callback_register)(VdpDevice device, VdpPreemptionCallback callback, void* context);
-+//-----------------------------------------------------------------------------
-+// VDPAU data structs
-+//-----------------------------------------------------------------------------
-
-- int surfaceNum;
-- int presentSurfaceNum;
-- int totalAvailableOutputSurfaces;
-- uint32_t vid_width, vid_height;
-- int surface_width, surface_height;
-- uint32_t max_references;
-- Display* m_Display;
-- bool vdpauConfigured;
-- uint32_t *m_BlackBar;
-+class CDecoder;
-+
-+/**
-+ * Buffer statistics used to control number of frames in queue
-+ */
-+
-+class CVdpauBufferStats
-+{
-+public:
-+ uint16_t decodedPics;
-+ uint16_t processedPics;
-+ uint16_t renderPics;
-+ uint64_t latency; // time decoder has waited for a frame, ideally there is no latency
-+ int playSpeed;
-+ bool canSkipDeint;
-+ int processCmd;
-+
-+ void IncDecoded() { CSingleLock l(m_sec); decodedPics++;}
-+ void DecDecoded() { CSingleLock l(m_sec); decodedPics--;}
-+ void IncProcessed() { CSingleLock l(m_sec); processedPics++;}
-+ void DecProcessed() { CSingleLock l(m_sec); processedPics--;}
-+ void IncRender() { CSingleLock l(m_sec); renderPics++;}
-+ void DecRender() { CSingleLock l(m_sec); renderPics--;}
-+ void Reset() { CSingleLock l(m_sec); decodedPics=0; processedPics=0;renderPics=0;latency=0;}
-+ void Get(uint16_t &decoded, uint16_t &processed, uint16_t &render) {CSingleLock l(m_sec); decoded = decodedPics, processed=processedPics, render=renderPics;}
-+ void SetParams(uint64_t time, int speed) { CSingleLock l(m_sec); latency = time; playSpeed = speed; }
-+ void GetParams(uint64_t &lat, int &speed) { CSingleLock l(m_sec); lat = latency; speed = playSpeed; }
-+ void SetCmd(int cmd) { CSingleLock l(m_sec); processCmd = cmd; }
-+ void GetCmd(int &cmd) { CSingleLock l(m_sec); cmd = processCmd; processCmd = 0; }
-+ void SetCanSkipDeint(bool canSkip) { CSingleLock l(m_sec); canSkipDeint = canSkip; }
-+ bool CanSkipDeint() { CSingleLock l(m_sec); if (canSkipDeint) return true; else return false;}
-+private:
-+ CCriticalSection m_sec;
-+};
-+
-+/**
-+ * CVdpauConfig holds all configuration parameters needed by vdpau
-+ * The structure is sent to the internal classes CMixer and COutput
-+ * for init.
-+ */
-+
-+struct CVdpauConfig
-+{
-+ int surfaceWidth;
-+ int surfaceHeight;
-+ int vidWidth;
-+ int vidHeight;
-+ int outWidth;
-+ int outHeight;
-+ VDPAU_procs vdpProcs;
-+ VdpDevice vdpDevice;
-+ VdpDecoder vdpDecoder;
-+ VdpChromaType vdpChromaType;
-+ CVdpauBufferStats *stats;
-+ CDecoder *vdpau;
-+ int featureCount;
-+ int upscale;
-+ VdpVideoMixerFeature vdpFeatures[10];
-+ std::vector *videoSurfaces;
-+ CCriticalSection *videoSurfaceSec;
-+ bool usePixmaps;
-+ int numRenderBuffers;
-+ uint32_t maxReferences;
-+ bool useInteropYuv;
-+};
-+
-+/**
-+ * Holds a decoded frame
-+ * Input to COutput for further processing
-+ */
-+struct CVdpauDecodedPicture
-+{
-+ DVDVideoPicture DVDPic;
-+ vdpau_render_state *render;
-+};
-+
-+/**
-+ * Frame after having been processed by vdpau mixer
-+ */
-+struct CVdpauProcessedPicture
-+{
-+ DVDVideoPicture DVDPic;
-+ vdpau_render_state *render;
-+ VdpOutputSurface outputSurface;
-+};
-
-+/**
-+ * Ready to render textures
-+ * Sent from COutput back to CDecoder
-+ * Objects are referenced by DVDVideoPicture and are sent
-+ * to renderer
-+ */
-+class CVdpauRenderPicture
-+{
-+ friend class CDecoder;
-+ friend class COutput;
-+public:
-+ DVDVideoPicture DVDPic;
-+ int texWidth, texHeight;
-+ CRect crop;
-+ GLuint texture[4];
-+ uint32_t sourceIdx;
-+ bool valid;
-+ CDecoder *vdpau;
-+ CVdpauRenderPicture* Acquire();
-+ long Release();
-+private:
-+ void ReturnUnused();
-+ int refCount;
-+ CCriticalSection *renderPicSection;
-+};
-
-+//-----------------------------------------------------------------------------
-+// Mixer
-+//-----------------------------------------------------------------------------
-+
-+class CMixerControlProtocol : public Protocol
-+{
-+public:
-+ CMixerControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ INIT = 0,
-+ FLUSH,
-+ TIMEOUT,
-+ };
-+ enum InSignal
-+ {
-+ ACC,
-+ ERROR,
-+ };
-+};
-+
-+class CMixerDataProtocol : public Protocol
-+{
-+public:
-+ CMixerDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ FRAME,
-+ BUFFER,
-+ };
-+ enum InSignal
-+ {
-+ PICTURE,
-+ };
-+};
-+
-+/**
-+ * Embeds the vdpau video mixer
-+ * Embedded by COutput class, gets decoded frames from COutput, processes
-+ * them in mixer ands sends processed frames back to COutput
-+ */
-+class CMixer : private CThread
-+{
-+public:
-+ CMixer(CEvent *inMsgEvent);
-+ virtual ~CMixer();
-+ void Start();
-+ void Dispose();
-+ CMixerControlProtocol m_controlPort;
-+ CMixerDataProtocol m_dataPort;
-+protected:
-+ void OnStartup();
-+ void OnExit();
-+ void Process();
-+ void StateMachine(int signal, Protocol *port, Message *msg);
-+ void Init();
-+ void Uninit();
-+ void Flush();
-+ void CreateVdpauMixer();
-+ void ProcessPicture();
-+ void InitCycle();
-+ void FiniCycle();
-+ void CheckFeatures();
-+ void SetPostProcFeatures(bool postProcEnabled);
-+ void PostProcOff();
-+ void InitCSCMatrix(int Width);
-+ bool GenerateStudioCSCMatrix(VdpColorStandard colorStandard, VdpCSCMatrix &studioCSCMatrix);
-+ void SetColor();
-+ void SetNoiseReduction();
-+ void SetSharpness();
-+ void SetDeintSkipChroma();
-+ void SetDeinterlacing();
-+ void SetHWUpscaling();
-+ void DisableHQScaling();
-+ EINTERLACEMETHOD GetDeinterlacingMethod(bool log = false);
-+ bool CheckStatus(VdpStatus vdp_st, int line);
-+ CEvent m_outMsgEvent;
-+ CEvent *m_inMsgEvent;
-+ int m_state;
-+ bool m_bStateMachineSelfTrigger;
-+
-+ // extended state variables for state machine
-+ int m_extTimeout;
-+ bool m_vdpError;
-+ CVdpauConfig m_config;
-+ VdpVideoMixer m_videoMixer;
-+ VdpProcamp m_Procamp;
-+ VdpCSCMatrix m_CSCMatrix;
-+ bool m_PostProc;
-+ float m_Brightness;
-+ float m_Contrast;
-+ float m_NoiseReduction;
-+ float m_Sharpness;
-+ int m_DeintMode;
-+ int m_Deint;
-+ int m_Upscale;
-+ uint32_t *m_BlackBar;
- VdpVideoMixerPictureStructure m_mixerfield;
-- int m_mixerstep;
-+ int m_mixerstep;
-+ int m_mixersteps;
-+ CVdpauProcessedPicture m_processPicture;
-+ std::queue m_outputSurfaces;
-+ std::queue m_decodedPics;
-+ std::deque m_mixerInput;
-+};
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+
-+/**
-+ * Buffer pool holds allocated vdpau and gl resources
-+ * Embedded in COutput
-+ */
-+struct VdpauBufferPool
-+{
-+ struct Pixmaps
-+ {
-+ unsigned short id;
-+ bool used;
-+ DVDVideoPicture DVDPic;
-+ GLuint texture;
-+ Pixmap pixmap;
-+ GLXPixmap glPixmap;
-+ VdpPresentationQueueTarget vdp_flip_target;
-+ VdpPresentationQueue vdp_flip_queue;
-+ VdpOutputSurface surface;
-+ };
-+ struct GLVideoSurface
-+ {
-+ GLuint texture[4];
-+#ifdef GL_NV_vdpau_interop
-+ GLvdpauSurfaceNV glVdpauSurface;
-+#endif
-+ vdpau_render_state *sourceVuv;
-+ VdpOutputSurface sourceRgb;
-+ };
-+ unsigned short numOutputSurfaces;
-+ std::vector pixmaps;
-+ std::vector outputSurfaces;
-+ std::deque notVisiblePixmaps;
-+ std::vector allRenderPics;
-+ std::map glVideoSurfaceMap;
-+ std::map glOutputSurfaceMap;
-+ std::queue processedPics;
-+ std::deque usedRenderPics;
-+ std::deque freeRenderPics;
-+ CCriticalSection renderPicSec;
-+};
-+
-+class COutputControlProtocol : public Protocol
-+{
-+public:
-+ COutputControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ INIT,
-+ FLUSH,
-+ PRECLEANUP,
-+ TIMEOUT,
-+ };
-+ enum InSignal
-+ {
-+ ACC,
-+ ERROR,
-+ STATS,
-+ };
-+};
-+
-+class COutputDataProtocol : public Protocol
-+{
-+public:
-+ COutputDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ NEWFRAME = 0,
-+ RETURNPIC,
-+ };
-+ enum InSignal
-+ {
-+ PICTURE,
-+ };
-+};
-+
-+/**
-+ * COutput is embedded in CDecoder and embeds CMixer
-+ * The class has its own OpenGl context which is shared with render thread
-+ * COuput generated ready to render textures and passes them back to
-+ * CDecoder
-+ */
-+class COutput : private CThread
-+{
-+public:
-+ COutput(CEvent *inMsgEvent);
-+ virtual ~COutput();
-+ void Start();
-+ void Dispose();
-+ COutputControlProtocol m_controlPort;
-+ COutputDataProtocol m_dataPort;
-+protected:
-+ void OnStartup();
-+ void OnExit();
-+ void Process();
-+ void StateMachine(int signal, Protocol *port, Message *msg);
-+ bool HasWork();
-+ CVdpauRenderPicture *ProcessMixerPicture();
-+ void ProcessReturnPicture(CVdpauRenderPicture *pic);
-+ int FindFreePixmap();
-+ bool Init();
-+ bool Uninit();
-+ void Flush();
-+ bool CreateGlxContext();
-+ bool DestroyGlxContext();
-+ bool EnsureBufferPool();
-+ void ReleaseBufferPool();
-+ void InitMixer();
-+ bool GLInit();
-+ void GLMapSurfaces();
-+ void GLUnmapSurfaces();
-+ void GLBindPixmaps();
-+ void GLUnbindPixmaps();
-+ bool MakePixmap(VdpauBufferPool::Pixmaps &pixmap);
-+ bool MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap);
-+ bool CheckStatus(VdpStatus vdp_st, int line);
-+ CEvent m_outMsgEvent;
-+ CEvent *m_inMsgEvent;
-+ int m_state;
-+ bool m_bStateMachineSelfTrigger;
-+
-+ // extended state variables for state machine
-+ int m_extTimeout;
-+ bool m_vdpError;
-+ CVdpauConfig m_config;
-+ VdpauBufferPool m_bufferPool;
-+ CMixer m_mixer;
-+ Display *m_Display;
-+ Window m_Window;
-+ GLXContext m_glContext;
-+ GLXWindow m_glWindow;
-+ Pixmap m_pixmap;
-+ GLXPixmap m_glPixmap;
-+
-+ // gl functions
-+ PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT;
-+ PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT;
-+#ifdef GL_NV_vdpau_interop
-+ PFNGLVDPAUINITNVPROC glVDPAUInitNV;
-+ PFNGLVDPAUFININVPROC glVDPAUFiniNV;
-+ PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC glVDPAURegisterOutputSurfaceNV;
-+ PFNGLVDPAUREGISTERVIDEOSURFACENVPROC glVDPAURegisterVideoSurfaceNV;
-+ PFNGLVDPAUISSURFACENVPROC glVDPAUIsSurfaceNV;
-+ PFNGLVDPAUUNREGISTERSURFACENVPROC glVDPAUUnregisterSurfaceNV;
-+ PFNGLVDPAUSURFACEACCESSNVPROC glVDPAUSurfaceAccessNV;
-+ PFNGLVDPAUMAPSURFACESNVPROC glVDPAUMapSurfacesNV;
-+ PFNGLVDPAUUNMAPSURFACESNVPROC glVDPAUUnmapSurfacesNV;
-+ PFNGLVDPAUGETSURFACEIVNVPROC glVDPAUGetSurfaceivNV;
-+#endif
-+};
-+
-+//-----------------------------------------------------------------------------
-+// VDPAU decoder
-+//-----------------------------------------------------------------------------
-+
-+/**
-+ * VDPAU main class
-+ */
-+class CDecoder
-+ : public CDVDVideoCodecFFmpeg::IHardwareDecoder
-+ , public IDispResource
-+{
-+ friend class CVdpauRenderPicture;
-+
-+public:
-+
-+ struct PictureAge
-+ {
-+ int b_age;
-+ int ip_age[2];
-+ };
-+
-+ struct Desc
-+ {
-+ const char *name;
-+ uint32_t id;
-+ uint32_t aux; /* optional extra parameter... */
-+ };
-+
-+ CDecoder();
-+ virtual ~CDecoder();
-+
-+ virtual bool Open (AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces = 0);
-+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame) {return Decode(avctx, frame, false, false);};
-+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame, bool bSoftDrain = false, bool bHardDrain = false);
-+ virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture);
-+ virtual void Reset();
-+ virtual void Close();
-+ virtual long Release();
-+ virtual bool CanSkipDeint();
-+ virtual void SetSpeed(int speed);
-+
-+ virtual int Check(AVCodecContext* avctx);
-+ virtual const std::string Name() { return "vdpau"; }
-
- bool Supports(VdpVideoMixerFeature feature);
- bool Supports(EINTERLACEMETHOD method);
- EINTERLACEMETHOD AutoInterlaceMethod();
-+ static bool IsVDPAUFormat(PixelFormat fmt);
-
-- VdpVideoMixerFeature m_features[10];
-- int m_feature_count;
-+ static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic);
-+ static void FFDrawSlice(struct AVCodecContext *s,
-+ const AVFrame *src, int offset[4],
-+ int y, int type, int height);
-+ static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
-+
-+ virtual void OnLostDevice();
-+ virtual void OnResetDevice();
-+
-+protected:
-+ void SetWidthHeight(int width, int height);
-+ bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames);
-+ void SpewHardwareAvailable();
-+ bool CheckStatus(VdpStatus vdp_st, int line);
-+ bool IsSurfaceValid(vdpau_render_state *render);
-+ void InitVDPAUProcs();
-+ void FiniVDPAUProcs();
-+ void FiniVDPAUOutput();
-+ void ReturnRenderPicture(CVdpauRenderPicture *renderPic);
-+ long ReleasePicReference();
-
-- static bool IsVDPAUFormat(PixelFormat fmt);
- static void ReadFormatOf( PixelFormat fmt
- , VdpDecoderProfile &decoder_profile
- , VdpChromaType &chroma_type);
-
-- std::vector m_videoSurfaces;
-- DllAvUtil m_dllAvUtil;
--
-- enum VDPAUOutputMethod
-- {
-- OUTPUT_NONE,
-- OUTPUT_PIXMAP,
-- OUTPUT_GL_INTEROP_RGB,
-- OUTPUT_GL_INTEROP_YUV
-- };
-- VDPAUOutputMethod m_vdpauOutputMethod;
-+ VdpStatus (*dl_vdp_device_create_x11)(Display* display, int screen, VdpDevice* device, VdpGetProcAddress **get_proc_address);
-+ VdpStatus (*dl_vdp_get_proc_address)(VdpDevice device, VdpFuncId function_id, void** function_pointer);
-+ VdpStatus (*dl_vdp_preemption_callback_register)(VdpDevice device, VdpPreemptionCallback callback, void* context);
-
- // OnLostDevice triggers transition from all states to LOST
- // internal errors trigger transition from OPEN to RESET
-@@ -247,9 +580,27 @@
- , VDPAU_LOST
- , VDPAU_ERROR
- } m_DisplayState;
-- CSharedSection m_DecoderSection;
-- CSharedSection m_DisplaySection;
-+ CCriticalSection m_DecoderSection;
- CEvent m_DisplayEvent;
-- virtual void OnLostDevice();
-- virtual void OnResetDevice();
-+
-+ static void* dl_handle;
-+ DllAvUtil m_dllAvUtil;
-+ Display* m_Display;
-+ ThreadIdentifier m_decoderThread;
-+ bool m_vdpauConfigured;
-+ CVdpauConfig m_vdpauConfig;
-+ std::vector m_videoSurfaces;
-+ CCriticalSection m_videoSurfaceSec;
-+ PictureAge m_picAge;
-+
-+ COutput m_vdpauOutput;
-+ CVdpauBufferStats m_bufferStats;
-+ CEvent m_inMsgEvent;
-+ CVdpauRenderPicture *m_presentPicture;
-+
-+ int m_speed;
-+ int m_codecControl;
- };
-+
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp 2012-05-14 14:15:12.135220486 +0200
-@@ -0,0 +1,2382 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#include "system.h"
-+#ifdef HAVE_LIBXVBA
-+#include
-+#include
-+#include "XVBA.h"
-+#include "windowing/WindowingFactory.h"
-+#include "guilib/GraphicContext.h"
-+#include "settings/GUISettings.h"
-+#include "settings/Settings.h"
-+#include "utils/TimeUtils.h"
-+#include "cores/dvdplayer/DVDClock.h"
-+
-+using namespace XVBA;
-+
-+// XVBA interface
-+
-+#define XVBA_LIBRARY "libXvBAW.so.1"
-+
-+typedef Bool (*XVBAQueryExtensionProc) (Display *dpy, int *vers);
-+typedef Status (*XVBACreateContextProc) (void *input, void *output);
-+typedef Status (*XVBADestroyContextProc) (void *context);
-+typedef Bool (*XVBAGetSessionInfoProc) (void *input, void *output);
-+typedef Status (*XVBACreateSurfaceProc) (void *input, void *output);
-+typedef Status (*XVBACreateGLSharedSurfaceProc)(void *input, void *output);
-+typedef Status (*XVBADestroySurfaceProc) (void *surface);
-+typedef Status (*XVBACreateDecodeBuffersProc) (void *input, void *output);
-+typedef Status (*XVBADestroyDecodeBuffersProc) (void *input);
-+typedef Status (*XVBAGetCapDecodeProc) (void *input, void *output);
-+typedef Status (*XVBACreateDecodeProc) (void *input, void *output);
-+typedef Status (*XVBADestroyDecodeProc) (void *session);
-+typedef Status (*XVBAStartDecodePictureProc) (void *input);
-+typedef Status (*XVBADecodePictureProc) (void *input);
-+typedef Status (*XVBAEndDecodePictureProc) (void *input);
-+typedef Status (*XVBASyncSurfaceProc) (void *input, void *output);
-+typedef Status (*XVBAGetSurfaceProc) (void *input);
-+typedef Status (*XVBATransferSurfaceProc) (void *input);
-+
-+static struct
-+{
-+ XVBAQueryExtensionProc QueryExtension;
-+ XVBACreateContextProc CreateContext;
-+ XVBADestroyContextProc DestroyContext;
-+ XVBAGetSessionInfoProc GetSessionInfo;
-+ XVBACreateSurfaceProc CreateSurface;
-+ XVBACreateGLSharedSurfaceProc CreateGLSharedSurface;
-+ XVBADestroySurfaceProc DestroySurface;
-+ XVBACreateDecodeBuffersProc CreateDecodeBuffers;
-+ XVBADestroyDecodeBuffersProc DestroyDecodeBuffers;
-+ XVBAGetCapDecodeProc GetCapDecode;
-+ XVBACreateDecodeProc CreateDecode;
-+ XVBADestroyDecodeProc DestroyDecode;
-+ XVBAStartDecodePictureProc StartDecodePicture;
-+ XVBADecodePictureProc DecodePicture;
-+ XVBAEndDecodePictureProc EndDecodePicture;
-+ XVBASyncSurfaceProc SyncSurface;
-+ XVBAGetSurfaceProc GetSurface;
-+ XVBATransferSurfaceProc TransferSurface;
-+}g_XVBA_vtable;
-+
-+//-----------------------------------------------------------------------------
-+//-----------------------------------------------------------------------------
-+
-+CXVBAContext *CXVBAContext::m_context = 0;
-+CCriticalSection CXVBAContext::m_section;
-+Display *CXVBAContext::m_display = 0;
-+void *CXVBAContext::m_dlHandle = 0;
-+
-+CXVBAContext::CXVBAContext()
-+{
-+ m_context = 0;
-+// m_dlHandle = 0;
-+ m_xvbaContext = 0;
-+ m_refCount = 0;
-+}
-+
-+void CXVBAContext::Release()
-+{
-+ CSingleLock lock(m_section);
-+
-+ m_refCount--;
-+ if (m_refCount <= 0)
-+ {
-+ Close();
-+ delete this;
-+ m_context = 0;
-+ }
-+}
-+
-+void CXVBAContext::Close()
-+{
-+ CLog::Log(LOGNOTICE, "XVBA::Close - closing decoder context");
-+
-+ DestroyContext();
-+// if (m_dlHandle)
-+// {
-+// dlclose(m_dlHandle);
-+// m_dlHandle = 0;
-+// }
-+}
-+
-+bool CXVBAContext::EnsureContext(CXVBAContext **ctx)
-+{
-+ CSingleLock lock(m_section);
-+
-+ if (m_context)
-+ {
-+ m_context->m_refCount++;
-+ *ctx = m_context;
-+ return true;
-+ }
-+
-+ m_context = new CXVBAContext();
-+ *ctx = m_context;
-+ {
-+ CSingleLock gLock(g_graphicsContext);
-+ if (!m_context->LoadSymbols() || !m_context->CreateContext())
-+ {
-+ delete m_context;
-+ m_context = 0;
-+ return false;
-+ }
-+ }
-+
-+ m_context->m_refCount++;
-+
-+ *ctx = m_context;
-+ return true;
-+}
-+
-+bool CXVBAContext::LoadSymbols()
-+{
-+ if (!m_dlHandle)
-+ {
-+ m_dlHandle = dlopen(XVBA_LIBRARY, RTLD_LAZY);
-+ if (!m_dlHandle)
-+ {
-+ const char* error = dlerror();
-+ if (!error)
-+ error = "dlerror() returned NULL";
-+
-+ CLog::Log(LOGERROR,"XVBA::LoadSymbols: Unable to get handle to lib: %s", error);
-+ return false;
-+ }
-+ }
-+ else
-+ return true;
-+
-+#define INIT_PROC(PREFIX, PROC) do { \
-+ g_##PREFIX##_vtable.PROC = (PREFIX##PROC##Proc) \
-+ dlsym(m_dlHandle, #PREFIX #PROC); \
-+ } while (0)
-+
-+#define INIT_PROC_CHECK(PREFIX, PROC) do { \
-+ dlerror(); \
-+ INIT_PROC(PREFIX, PROC); \
-+ if (dlerror()) { \
-+ dlclose(m_dlHandle); \
-+ m_dlHandle = NULL; \
-+ return false; \
-+ } \
-+ } while (0)
-+
-+#define XVBA_INIT_PROC(PROC) INIT_PROC_CHECK(XVBA, PROC)
-+
-+ XVBA_INIT_PROC(QueryExtension);
-+ XVBA_INIT_PROC(CreateContext);
-+ XVBA_INIT_PROC(DestroyContext);
-+ XVBA_INIT_PROC(GetSessionInfo);
-+ XVBA_INIT_PROC(CreateSurface);
-+ XVBA_INIT_PROC(CreateGLSharedSurface);
-+ XVBA_INIT_PROC(DestroySurface);
-+ XVBA_INIT_PROC(CreateDecodeBuffers);
-+ XVBA_INIT_PROC(DestroyDecodeBuffers);
-+ XVBA_INIT_PROC(GetCapDecode);
-+ XVBA_INIT_PROC(CreateDecode);
-+ XVBA_INIT_PROC(DestroyDecode);
-+ XVBA_INIT_PROC(StartDecodePicture);
-+ XVBA_INIT_PROC(DecodePicture);
-+ XVBA_INIT_PROC(EndDecodePicture);
-+ XVBA_INIT_PROC(SyncSurface);
-+ XVBA_INIT_PROC(GetSurface);
-+ XVBA_INIT_PROC(TransferSurface);
-+
-+#undef XVBA_INIT_PROC
-+#undef INIT_PROC
-+
-+ return true;
-+}
-+
-+bool CXVBAContext::CreateContext()
-+{
-+ if (m_xvbaContext)
-+ return true;
-+
-+ CLog::Log(LOGNOTICE,"XVBA::CreateContext - creating decoder context");
-+
-+ Drawable window;
-+ { CSingleLock lock(g_graphicsContext);
-+ if (!m_display)
-+ m_display = XOpenDisplay(NULL);
-+ window = 0;
-+ }
-+
-+ int version;
-+ if (!g_XVBA_vtable.QueryExtension(m_display, &version))
-+ return false;
-+ CLog::Log(LOGNOTICE,"XVBA::CreateContext - opening xvba version: %i", version);
-+
-+ // create XVBA Context
-+ XVBA_Create_Context_Input contextInput;
-+ XVBA_Create_Context_Output contextOutput;
-+ contextInput.size = sizeof(contextInput);
-+ contextInput.display = m_display;
-+ contextInput.draw = window;
-+ contextOutput.size = sizeof(contextOutput);
-+ if(Success != g_XVBA_vtable.CreateContext(&contextInput, &contextOutput))
-+ {
-+ CLog::Log(LOGERROR,"XVBA::CreateContext - failed to create context");
-+ return false;
-+ }
-+ m_xvbaContext = contextOutput.context;
-+
-+ return true;
-+}
-+
-+void CXVBAContext::DestroyContext()
-+{
-+ if (!m_xvbaContext)
-+ return;
-+
-+ g_XVBA_vtable.DestroyContext(m_xvbaContext);
-+ m_xvbaContext = 0;
-+// XCloseDisplay(m_display);
-+}
-+
-+void *CXVBAContext::GetContext()
-+{
-+ return m_xvbaContext;
-+}
-+
-+//-----------------------------------------------------------------------------
-+//-----------------------------------------------------------------------------
-+
-+static unsigned int decoderId = 0;
-+
-+CDecoder::CDecoder() : m_xvbaOutput(&m_inMsgEvent)
-+{
-+ m_xvbaConfig.context = 0;
-+ m_xvbaConfig.xvbaSession = 0;
-+ m_xvbaConfig.videoSurfaces = &m_videoSurfaces;
-+ m_xvbaConfig.videoSurfaceSec = &m_videoSurfaceSec;
-+ m_xvbaConfig.apiSec = &m_apiSec;
-+
-+ m_displayState = XVBA_OPEN;
-+}
-+
-+CDecoder::~CDecoder()
-+{
-+ Close();
-+}
-+
-+typedef struct {
-+ unsigned int size;
-+ unsigned int num_of_decodecaps;
-+ XVBADecodeCap decode_caps_list[];
-+} XVBA_GetCapDecode_Output_Base;
-+
-+void CDecoder::OnLostDevice()
-+{
-+ CLog::Log(LOGNOTICE,"XVBA::OnLostDevice event");
-+
-+ CSingleLock lock(m_decoderSection);
-+ DestroySession();
-+ if (m_xvbaConfig.context)
-+ m_xvbaConfig.context->Release();
-+ m_xvbaConfig.context = 0;
-+
-+ m_displayState = XVBA_LOST;
-+ m_displayEvent.Reset();
-+}
-+
-+void CDecoder::OnResetDevice()
-+{
-+ CLog::Log(LOGNOTICE,"XVBA::OnResetDevice event");
-+
-+ CSingleLock lock(m_decoderSection);
-+ if (m_displayState == XVBA_LOST)
-+ {
-+ m_displayState = XVBA_RESET;
-+ lock.Leave();
-+ m_displayEvent.Set();
-+ }
-+}
-+
-+bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned int surfaces)
-+{
-+ std::string Vendor = g_Windowing.GetRenderVendor();
-+ std::transform(Vendor.begin(), Vendor.end(), Vendor.begin(), ::tolower);
-+ if (Vendor.compare(0, 3, "ati") != 0)
-+ {
-+ return false;
-+ }
-+
-+ m_decoderId = decoderId++;
-+
-+ CLog::Log(LOGNOTICE,"(XVBA::Open) opening xvba decoder, id: %d", m_decoderId);
-+
-+ if(avctx->coded_width == 0
-+ || avctx->coded_height == 0)
-+ {
-+ CLog::Log(LOGWARNING,"(XVBA) no width/height available, can't init");
-+ return false;
-+ }
-+
-+ if (!m_dllAvUtil.Load())
-+ return false;
-+
-+ if (!CXVBAContext::EnsureContext(&m_xvbaConfig.context))
-+ return false;
-+
-+ // xvba get session info
-+ XVBA_GetSessionInfo_Input sessionInput;
-+ XVBA_GetSessionInfo_Output sessionOutput;
-+ sessionInput.size = sizeof(sessionInput);
-+ sessionInput.context = m_xvbaConfig.context->GetContext();
-+ sessionOutput.size = sizeof(sessionOutput);
-+ if (Success != g_XVBA_vtable.GetSessionInfo(&sessionInput, &sessionOutput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) can't get session info");
-+ return false;
-+ }
-+ if (sessionOutput.getcapdecode_output_size == 0)
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) session decode not supported");
-+ return false;
-+ }
-+
-+ // get decoder capabilities
-+ XVBA_GetCapDecode_Input capInput;
-+ XVBA_GetCapDecode_Output *capOutput;
-+ capInput.size = sizeof(capInput);
-+ capInput.context = m_xvbaConfig.context->GetContext();
-+ capOutput = (XVBA_GetCapDecode_Output *)calloc(sessionOutput.getcapdecode_output_size, 1);
-+ capOutput->size = sessionOutput.getcapdecode_output_size;
-+ if (Success != g_XVBA_vtable.GetCapDecode(&capInput, capOutput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) can't get decode capabilities");
-+ return false;
-+ }
-+
-+ int match = -1;
-+ if (avctx->codec_id == CODEC_ID_H264)
-+ {
-+ // search for profile high
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_H264 &&
-+ capOutput->decode_caps_list[i].flags == XVBA_H264_HIGH)
-+ {
-+ match = (int) i;
-+ break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_H264_HIGH not found");
-+ }
-+ }
-+ else if (avctx->codec_id == CODEC_ID_VC1)
-+ {
-+ // search for profile advanced
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_VC1 &&
-+ capOutput->decode_caps_list[i].flags == XVBA_VC1_ADVANCED)
-+ {
-+ match = (int) i;
-+ break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_VC1_ADVANCED not found");
-+ }
-+ }
-+ else if (avctx->codec_id == CODEC_ID_MPEG2VIDEO)
-+ {
-+ // search for profile high
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_MPEG2_VLD)
-+ {
-+ // XXX: uncomment when implemented
-+ // match = (int) i;
-+ // break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_MPEG2_VLD not found");
-+ }
-+ }
-+ else if (avctx->codec_id == CODEC_ID_WMV3)
-+ {
-+ // search for profile high
-+ for (unsigned int i = 0; i < capOutput->num_of_decodecaps; ++i)
-+ {
-+ if (capOutput->decode_caps_list[i].capability_id == XVBA_VC1 &&
-+ capOutput->decode_caps_list[i].flags == XVBA_VC1_MAIN)
-+ {
-+ match = (int) i;
-+ break;
-+ }
-+ }
-+ if (match < 0)
-+ {
-+ CLog::Log(LOGNOTICE, "(XVBA::Open) - profile XVBA_VC1_MAIN not found");
-+ }
-+ }
-+
-+ if (match < 0)
-+ {
-+ free(capOutput);
-+ return false;
-+ }
-+
-+ CLog::Log(LOGNOTICE,"(XVBA) using decoder capability id: %i flags: %i",
-+ capOutput->decode_caps_list[match].capability_id,
-+ capOutput->decode_caps_list[match].flags);
-+ CLog::Log(LOGNOTICE,"(XVBA) using surface type: %x",
-+ capOutput->decode_caps_list[match].surface_type);
-+
-+ m_xvbaConfig.decoderCap = capOutput->decode_caps_list[match];
-+
-+ free(capOutput);
-+
-+ // set some varables
-+ m_xvbaConfig.xvbaSession = 0;
-+ m_xvbaBufferPool.data_buffer = 0;
-+ m_xvbaBufferPool.iq_matrix_buffer = 0;
-+ m_xvbaBufferPool.picture_descriptor_buffer = 0;
-+ picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
-+ m_presentPicture = 0;
-+ m_xvbaConfig.numRenderBuffers = surfaces;
-+ m_decoderThread = CThread::GetCurrentThreadId();
-+ m_speed = DVD_PLAYSPEED_NORMAL;
-+
-+ if (1) //g_guiSettings.GetBool("videoplayer.usexvbasharedsurface"))
-+ m_xvbaConfig.useSharedSurfaces = true;
-+ else
-+ m_xvbaConfig.useSharedSurfaces = false;
-+
-+ m_displayState = XVBA_OPEN;
-+
-+ // setup ffmpeg
-+ avctx->thread_count = 1;
-+ avctx->get_buffer = CDecoder::FFGetBuffer;
-+ avctx->release_buffer = CDecoder::FFReleaseBuffer;
-+ avctx->draw_horiz_band = CDecoder::FFDrawSlice;
-+ avctx->slice_flags = SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
-+
-+ g_Windowing.Register(this);
-+ return true;
-+}
-+
-+void CDecoder::Close()
-+{
-+ CLog::Log(LOGNOTICE, "XVBA::Close - closing decoder, id: %d", m_decoderId);
-+
-+ if (!m_xvbaConfig.context)
-+ return;
-+
-+ DestroySession();
-+ if (m_xvbaConfig.context)
-+ m_xvbaConfig.context->Release();
-+ m_xvbaConfig.context = 0;
-+
-+ while (!m_videoSurfaces.empty())
-+ {
-+ xvba_render_state *render = m_videoSurfaces.back();
-+ if(render->buffers_alllocated > 0)
-+ m_dllAvUtil.av_free(render->buffers);
-+ m_videoSurfaces.pop_back();
-+ free(render);
-+ }
-+
-+ g_Windowing.Unregister(this);
-+ m_dllAvUtil.Unload();
-+}
-+
-+long CDecoder::Release()
-+{
-+ // check if we should do some pre-cleanup here
-+ // a second decoder might need resources
-+ if (m_xvbaConfig.xvbaSession)
-+ {
-+ CSingleLock lock(m_decoderSection);
-+ CLog::Log(LOGNOTICE,"XVBA::Release pre-cleanup");
-+
-+ Message *reply;
-+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::PRECLEANUP,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - pre-cleanup returned error", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - pre-cleanup timed out", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+
-+ for(unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
-+ {
-+ xvba_render_state *render = m_videoSurfaces[i];
-+ if (render->surface && !(render->state & FF_XVBA_STATE_USED_FOR_RENDER))
-+ {
-+ g_XVBA_vtable.DestroySurface(render->surface);
-+ render->surface = 0;
-+ render->picture_descriptor = 0;
-+ render->iq_matrix = 0;
-+ }
-+ }
-+ }
-+ IHardwareDecoder::Release();
-+}
-+
-+long CDecoder::ReleasePicReference()
-+{
-+ return IHardwareDecoder::Release();
-+}
-+
-+bool CDecoder::Supports(EINTERLACEMETHOD method)
-+{
-+ if(method == VS_INTERLACEMETHOD_AUTO)
-+ return true;
-+
-+ if (1) //g_guiSettings.GetBool("videoplayer.usexvbasharedsurface"))
-+ {
-+ if (method == VS_INTERLACEMETHOD_XVBA)
-+ return true;
-+ }
-+
-+ return false;
-+}
-+
-+void CDecoder::ResetState()
-+{
-+ picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
-+
-+ m_displayState = XVBA_OPEN;
-+}
-+
-+int CDecoder::Check(AVCodecContext* avctx)
-+{
-+ EDisplayState state;
-+
-+ { CSingleLock lock(m_decoderSection);
-+ state = m_displayState;
-+ }
-+
-+ if (state == XVBA_LOST)
-+ {
-+ CLog::Log(LOGNOTICE,"XVBA::Check waiting for display reset event");
-+ if (!m_displayEvent.WaitMSec(2000))
-+ {
-+ CLog::Log(LOGERROR, "XVBA::Check - device didn't reset in reasonable time");
-+ state = XVBA_RESET;;
-+ }
-+ else
-+ { CSingleLock lock(m_decoderSection);
-+ state = m_displayState;
-+ }
-+ }
-+ if (state == XVBA_RESET || state == XVBA_ERROR)
-+ {
-+ CLog::Log(LOGNOTICE,"XVBA::Check - Attempting recovery");
-+
-+ CSingleLock gLock(g_graphicsContext);
-+ CSingleLock lock(m_decoderSection);
-+
-+ DestroySession();
-+ ResetState();
-+ CXVBAContext::EnsureContext(&m_xvbaConfig.context);
-+
-+ if (state == XVBA_RESET)
-+ return VC_FLUSHED;
-+ else
-+ return VC_ERROR;
-+ }
-+ return 0;
-+}
-+
-+void CDecoder::SetError(const char* function, const char* msg, int line)
-+{
-+ CLog::Log(LOGERROR, "XVBA::%s - %s, line %d", function, msg, line);
-+ CSingleLock lock(m_decoderSection);
-+ m_displayState = XVBA_ERROR;
-+}
-+
-+bool CDecoder::CreateSession(AVCodecContext* avctx)
-+{
-+ m_xvbaConfig.surfaceWidth = (avctx->coded_width+15) & ~15;
-+ m_xvbaConfig.surfaceHeight = (avctx->coded_height+15) & ~15;
-+
-+ m_xvbaConfig.vidWidth = avctx->width;
-+ m_xvbaConfig.vidHeight = avctx->height;
-+
-+ XVBA_Create_Decode_Session_Input sessionInput;
-+ XVBA_Create_Decode_Session_Output sessionOutput;
-+
-+ sessionInput.size = sizeof(sessionInput);
-+ sessionInput.width = m_xvbaConfig.surfaceWidth;
-+ sessionInput.height = m_xvbaConfig.surfaceHeight;
-+ sessionInput.context = m_xvbaConfig.context->GetContext();
-+ sessionInput.decode_cap = &m_xvbaConfig.decoderCap;
-+ sessionOutput.size = sizeof(sessionOutput);
-+
-+ if (Success != g_XVBA_vtable.CreateDecode(&sessionInput, &sessionOutput))
-+ {
-+ SetError(__FUNCTION__, "failed to create decoder session", __LINE__);
-+ CLog::Log(LOGERROR, "Decoder failed with following stats: m_surfaceWidth %u, m_surfaceHeight %u,"
-+ " m_vidWidth %u, m_vidHeight %u, coded_width %d, coded_height %d",
-+ m_xvbaConfig.surfaceWidth,
-+ m_xvbaConfig.surfaceHeight,
-+ m_xvbaConfig.vidWidth,
-+ m_xvbaConfig.vidHeight,
-+ avctx->coded_width,
-+ avctx->coded_height);
-+ return false;
-+ }
-+ m_xvbaConfig.xvbaSession = sessionOutput.session;
-+
-+ // create decode buffers
-+ XVBA_Create_DecodeBuff_Input bufferInput;
-+ XVBA_Create_DecodeBuff_Output bufferOutput;
-+
-+ bufferInput.size = sizeof(bufferInput);
-+ bufferInput.session = m_xvbaConfig.xvbaSession;
-+ bufferInput.buffer_type = XVBA_PICTURE_DESCRIPTION_BUFFER;
-+ bufferInput.num_of_buffers = 1;
-+ bufferOutput.size = sizeof(bufferOutput);
-+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput)
-+ || bufferOutput.num_of_buffers_in_list != 1)
-+ {
-+ SetError(__FUNCTION__, "failed to create picture buffer", __LINE__);
-+ return false;
-+ }
-+ m_xvbaBufferPool.picture_descriptor_buffer = bufferOutput.buffer_list;
-+
-+ // data buffer
-+ bufferInput.buffer_type = XVBA_DATA_BUFFER;
-+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput)
-+ || bufferOutput.num_of_buffers_in_list != 1)
-+ {
-+ SetError(__FUNCTION__, "failed to create data buffer", __LINE__);
-+ return false;
-+ }
-+ m_xvbaBufferPool.data_buffer = bufferOutput.buffer_list;
-+
-+ // QO Buffer
-+ bufferInput.buffer_type = XVBA_QM_BUFFER;
-+ if (Success != g_XVBA_vtable.CreateDecodeBuffers(&bufferInput, &bufferOutput)
-+ || bufferOutput.num_of_buffers_in_list != 1)
-+ {
-+ SetError(__FUNCTION__, "failed to create qm buffer", __LINE__);
-+ return false;
-+ }
-+ m_xvbaBufferPool.iq_matrix_buffer = bufferOutput.buffer_list;
-+
-+
-+ // initialize output
-+ CSingleLock lock(g_graphicsContext);
-+ m_xvbaConfig.stats = &m_bufferStats;
-+ m_bufferStats.Reset();
-+ m_xvbaOutput.Start();
-+ Message *reply;
-+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::INIT,
-+ &reply,
-+ 2000,
-+ &m_xvbaConfig,
-+ sizeof(m_xvbaConfig)))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - vdpau output returned error", __FUNCTION__);
-+ m_xvbaOutput.Dispose();
-+ return false;
-+ }
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - failed to init output", __FUNCTION__);
-+ m_xvbaOutput.Dispose();
-+ return false;
-+ }
-+ m_inMsgEvent.Reset();
-+
-+ return true;
-+}
-+
-+void CDecoder::DestroySession()
-+{
-+ m_xvbaOutput.Dispose();
-+
-+ XVBA_Destroy_Decode_Buffers_Input bufInput;
-+ bufInput.size = sizeof(bufInput);
-+ bufInput.num_of_buffers_in_list = 1;
-+
-+ for (unsigned int i=0; isurface)
-+ {
-+ g_XVBA_vtable.DestroySurface(render->surface);
-+ render->surface = 0;
-+ render->picture_descriptor = 0;
-+ render->iq_matrix = 0;
-+ }
-+ }
-+
-+ if (m_xvbaConfig.xvbaSession)
-+ g_XVBA_vtable.DestroyDecode(m_xvbaConfig.xvbaSession);
-+ m_xvbaConfig.xvbaSession = 0;
-+}
-+
-+bool CDecoder::IsSurfaceValid(xvba_render_state *render)
-+{
-+ // find render state in queue
-+ bool found(false);
-+ unsigned int i;
-+ for(i = 0; i < m_videoSurfaces.size(); ++i)
-+ {
-+ if(m_videoSurfaces[i] == render)
-+ {
-+ found = true;
-+ break;
-+ }
-+ }
-+ if (!found)
-+ {
-+ CLog::Log(LOGERROR,"%s - video surface not found", __FUNCTION__);
-+ return false;
-+ }
-+ if (m_videoSurfaces[i]->surface == 0)
-+ {
-+ m_videoSurfaces[i]->state = 0;
-+ return false;
-+ }
-+
-+ return true;
-+}
-+
-+bool CDecoder::EnsureDataControlBuffers(unsigned int num)
-+{
-+ if (m_xvbaBufferPool.data_control_buffers.size() >= num)
-+ return true;
-+
-+ unsigned int missing = num - m_xvbaBufferPool.data_control_buffers.size();
-+
-+ XVBA_Create_DecodeBuff_Input bufferInput;
-+ XVBA_Create_DecodeBuff_Output bufferOutput;
-+ bufferInput.size = sizeof(bufferInput);
-+ bufferInput.session = m_xvbaConfig.xvbaSession;
-+ bufferInput.buffer_type = XVBA_DATA_CTRL_BUFFER;
-+ bufferInput.num_of_buffers = 1;
-+ bufferOutput.size = sizeof(bufferOutput);
-+
-+ for (unsigned int i=0; iopaque;
-+ CDecoder* xvba = (CDecoder*)ctx->GetHardware();
-+ unsigned int i;
-+
-+ CSingleLock lock(xvba->m_decoderSection);
-+
-+ xvba_render_state * render = NULL;
-+ render = (xvba_render_state*)pic->data[0];
-+ if(!render)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFReleaseBuffer - invalid context handle provided");
-+ return;
-+ }
-+
-+ for(i=0; i<4; i++)
-+ pic->data[i]= NULL;
-+
-+ // find render state in queue
-+ if (!xvba->IsSurfaceValid(render))
-+ {
-+ CLog::Log(LOGDEBUG, "XVBA::FFReleaseBuffer - ignoring invalid buffer");
-+ return;
-+ }
-+
-+ render->state &= ~FF_XVBA_STATE_USED_FOR_REFERENCE;
-+}
-+
-+void CDecoder::FFDrawSlice(struct AVCodecContext *avctx,
-+ const AVFrame *src, int offset[4],
-+ int y, int type, int height)
-+{
-+ CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-+ CDecoder* xvba = (CDecoder*)ctx->GetHardware();
-+
-+ CSingleLock lock(xvba->m_decoderSection);
-+
-+ if(xvba->m_displayState != XVBA_OPEN)
-+ return;
-+
-+ if(src->linesize[0] || src->linesize[1] || src->linesize[2]
-+ || offset[0] || offset[1] || offset[2])
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFDrawSlice - invalid linesizes or offsets provided");
-+ return;
-+ }
-+
-+ xvba_render_state * render;
-+
-+ render = (xvba_render_state*)src->data[0];
-+ if(!render)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFDrawSlice - invalid context handle provided");
-+ return;
-+ }
-+
-+ // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid
-+ if (!xvba->IsSurfaceValid(render))
-+ {
-+ CLog::Log(LOGWARNING, "XVBA::FFDrawSlice - ignoring invalid buffer");
-+ return;
-+ }
-+
-+ // decoding
-+ XVBA_Decode_Picture_Start_Input startInput;
-+ startInput.size = sizeof(startInput);
-+ startInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ startInput.target_surface = render->surface;
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.StartDecodePicture(&startInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to start decoding", __LINE__);
-+ return;
-+ }
-+ }
-+
-+ XVBA_Decode_Picture_Input picInput;
-+ picInput.size = sizeof(picInput);
-+ picInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ XVBABufferDescriptor *list[2];
-+ picInput.buffer_list = list;
-+ list[0] = xvba->m_xvbaBufferPool.picture_descriptor_buffer;
-+ picInput.num_of_buffers_in_list = 1;
-+ if (avctx->codec_id == CODEC_ID_H264)
-+ {
-+ list[1] = xvba->m_xvbaBufferPool.iq_matrix_buffer;
-+ picInput.num_of_buffers_in_list = 2;
-+ }
-+
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.DecodePicture(&picInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to decode picture 1", __LINE__);
-+ return;
-+ }
-+ }
-+
-+ if (!xvba->EnsureDataControlBuffers(render->num_slices))
-+ return;
-+
-+ XVBADataCtrl *dataControl;
-+ int location = 0;
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer = 0;
-+ for (unsigned int j = 0; j < render->num_slices; ++j)
-+ {
-+ int startCodeSize = 0;
-+ uint8_t startCode[] = {0x00,0x00,0x01};
-+ if (avctx->codec_id == CODEC_ID_H264)
-+ {
-+ startCodeSize = 3;
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location,
-+ startCode, 3);
-+ }
-+ else if (avctx->codec_id == CODEC_ID_VC1 &&
-+ (memcmp(render->buffers[j].buffer, startCode, 3) != 0))
-+ {
-+ startCodeSize = 4;
-+ uint8_t sdf = 0x0d;
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location,
-+ startCode, 3);
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location+3,
-+ &sdf, 1);
-+ }
-+ // check for potential buffer overwrite
-+ unsigned int bytesToCopy = render->buffers[j].size;
-+ unsigned int freeBufferSize = xvba->m_xvbaBufferPool.data_buffer->buffer_size -
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer;
-+ if (bytesToCopy >= freeBufferSize)
-+ {
-+ xvba->SetError(__FUNCTION__, "bitstream buffer too large, maybe corrupted packet", __LINE__);
-+ return;
-+ }
-+ memcpy((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+location+startCodeSize,
-+ render->buffers[j].buffer,
-+ render->buffers[j].size);
-+ dataControl = (XVBADataCtrl*)xvba->m_xvbaBufferPool.data_control_buffers[j]->bufferXVBA;
-+ dataControl->SliceDataLocation = location;
-+ dataControl->SliceBytesInBuffer = render->buffers[j].size+startCodeSize;
-+ dataControl->SliceBitsInBuffer = dataControl->SliceBytesInBuffer * 8;
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer += dataControl->SliceBytesInBuffer;
-+ location += dataControl->SliceBytesInBuffer;
-+ }
-+
-+ int bufSize = xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer;
-+ int padding = bufSize % 128;
-+ if (padding)
-+ {
-+ padding = 128 - padding;
-+ xvba->m_xvbaBufferPool.data_buffer->data_size_in_buffer += padding;
-+ memset((uint8_t*)xvba->m_xvbaBufferPool.data_buffer->bufferXVBA+bufSize,0,padding);
-+ }
-+
-+ picInput.num_of_buffers_in_list = 2;
-+ for (unsigned int i = 0; i < render->num_slices; ++i)
-+ {
-+ list[0] = xvba->m_xvbaBufferPool.data_buffer;
-+ list[0]->data_offset = 0;
-+ list[1] = xvba->m_xvbaBufferPool.data_control_buffers[i];
-+ list[1]->data_size_in_buffer = sizeof(*dataControl);
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.DecodePicture(&picInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to decode picture 2", __LINE__);
-+ return;
-+ }
-+ }
-+ }
-+ XVBA_Decode_Picture_End_Input endInput;
-+ endInput.size = sizeof(endInput);
-+ endInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.EndDecodePicture(&endInput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to decode picture 3", __LINE__);
-+ return;
-+ }
-+ }
-+
-+ // decode sync and error
-+ XVBA_Surface_Sync_Input syncInput;
-+ XVBA_Surface_Sync_Output syncOutput;
-+ syncInput.size = sizeof(syncInput);
-+ syncInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ syncInput.surface = render->surface;
-+ syncInput.query_status = XVBA_GET_SURFACE_STATUS;
-+ syncOutput.size = sizeof(syncOutput);
-+ int64_t start = CurrentHostCounter();
-+ while (1)
-+ {
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed sync surface 1", __LINE__);
-+ return;
-+ }
-+ }
-+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING))
-+ break;
-+ if (CurrentHostCounter() - start > CurrentHostFrequency())
-+ {
-+ xvba->SetError(__FUNCTION__, "timed out waiting for surface", __LINE__);
-+ break;
-+ }
-+ usleep(100);
-+ }
-+ render->state |= FF_XVBA_STATE_DECODED;
-+}
-+
-+int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
-+{
-+ CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
-+ CDecoder* xvba = (CDecoder*)ctx->GetHardware();
-+ struct pictureAge* pA = &xvba->picAge;
-+
-+ pic->data[0] =
-+ pic->data[1] =
-+ pic->data[2] =
-+ pic->data[3] = 0;
-+
-+ pic->linesize[0] =
-+ pic->linesize[1] =
-+ pic->linesize[2] =
-+ pic->linesize[3] = 0;
-+
-+ CSingleLock lock(xvba->m_decoderSection);
-+
-+ if(xvba->m_displayState != XVBA_OPEN)
-+ return -1;
-+
-+ if (xvba->m_xvbaConfig.xvbaSession == 0)
-+ {
-+ if (!xvba->CreateSession(avctx))
-+ return -1;
-+ }
-+
-+ xvba_render_state * render = NULL;
-+ // find unused surface
-+ { CSingleLock lock(xvba->m_videoSurfaceSec);
-+ for(unsigned int i = 0; i < xvba->m_videoSurfaces.size(); ++i)
-+ {
-+ if(!(xvba->m_videoSurfaces[i]->state & (FF_XVBA_STATE_USED_FOR_REFERENCE | FF_XVBA_STATE_USED_FOR_RENDER)))
-+ {
-+ render = xvba->m_videoSurfaces[i];
-+ render->state = 0;
-+ break;
-+ }
-+ }
-+ }
-+
-+ // create a new render state
-+ if (render == NULL)
-+ {
-+ render = (xvba_render_state*)calloc(sizeof(xvba_render_state), 1);
-+ if (render == NULL)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::FFGetBuffer - calloc failed");
-+ return -1;
-+ }
-+ render->surface = 0;
-+ render->buffers_alllocated = 0;
-+ CSingleLock lock(xvba->m_videoSurfaceSec);
-+ xvba->m_videoSurfaces.push_back(render);
-+ }
-+
-+ // create a new surface
-+ if (render->surface == 0)
-+ {
-+ XVBA_Create_Surface_Input surfaceInput;
-+ XVBA_Create_Surface_Output surfaceOutput;
-+ surfaceInput.size = sizeof(surfaceInput);
-+ surfaceInput.surface_type = xvba->m_xvbaConfig.decoderCap.surface_type;
-+ surfaceInput.width = xvba->m_xvbaConfig.surfaceWidth;
-+ surfaceInput.height = xvba->m_xvbaConfig.surfaceHeight;
-+ surfaceInput.session = xvba->m_xvbaConfig.xvbaSession;
-+ surfaceOutput.size = sizeof(surfaceOutput);
-+ { CSingleLock lock(xvba->m_apiSec);
-+ if (Success != g_XVBA_vtable.CreateSurface(&surfaceInput, &surfaceOutput))
-+ {
-+ xvba->SetError(__FUNCTION__, "failed to create video surface", __LINE__);
-+ return -1;
-+ }
-+ }
-+ render->surface = surfaceOutput.surface;
-+ render->picture_descriptor = (XVBAPictureDescriptor *)xvba->m_xvbaBufferPool.picture_descriptor_buffer->bufferXVBA;
-+ render->iq_matrix = (XVBAQuantMatrixAvc *)xvba->m_xvbaBufferPool.iq_matrix_buffer->bufferXVBA;
-+ CLog::Log(LOGDEBUG, "XVBA::FFGetBuffer - created video surface");
-+ }
-+
-+ if (render == NULL)
-+ return -1;
-+
-+ pic->data[0] = (uint8_t*)render;
-+
-+ if(pic->reference)
-+ {
-+ pic->age = pA->ip_age[0];
-+ pA->ip_age[0]= pA->ip_age[1]+1;
-+ pA->ip_age[1]= 1;
-+ pA->b_age++;
-+ }
-+ else
-+ {
-+ pic->age = pA->b_age;
-+ pA->ip_age[0]++;
-+ pA->ip_age[1]++;
-+ pA->b_age = 1;
-+ }
-+ pic->type= FF_BUFFER_TYPE_USER;
-+
-+ render->state |= FF_XVBA_STATE_USED_FOR_REFERENCE;
-+ render->state &= ~FF_XVBA_STATE_DECODED;
-+ pic->reordered_opaque= avctx->reordered_opaque;
-+
-+ return 0;
-+}
-+
-+int CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame)
-+{
-+ int result = Check(avctx);
-+ if (result)
-+ return result;
-+
-+ CSingleLock lock(m_decoderSection);
-+
-+ if(frame)
-+ { // we have a new frame from decoder
-+
-+ xvba_render_state * render = (xvba_render_state*)frame->data[0];
-+ if(!render)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::Decode - no render buffer");
-+ return VC_ERROR;
-+ }
-+
-+ // ffmpeg vc-1 decoder does not flush, make sure the data buffer is still valid
-+ if (!IsSurfaceValid(render))
-+ {
-+ CLog::Log(LOGWARNING, "XVBA::Decode - ignoring invalid buffer");
-+ return VC_BUFFER;
-+ }
-+ if (!(render->state & FF_XVBA_STATE_DECODED))
-+ {
-+ CLog::Log(LOGDEBUG, "XVBA::Decode - ffmpeg failed");
-+ return VC_BUFFER;
-+ }
-+
-+ CSingleLock lock(m_videoSurfaceSec);
-+ render->state |= FF_XVBA_STATE_USED_FOR_RENDER;
-+ lock.Leave();
-+
-+ // send frame to output for processing
-+ CXvbaDecodedPicture pic;
-+ memset(&pic.DVDPic, 0, sizeof(pic.DVDPic));
-+ ((CDVDVideoCodecFFmpeg*)avctx->opaque)->GetPictureCommon(&pic.DVDPic);
-+ pic.render = render;
-+ m_bufferStats.IncDecoded();
-+ m_xvbaOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic));
-+
-+ m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_SKIP_PROC);
-+ if (m_codecControl & DVP_FLAG_SKIP_PROC)
-+ {
-+ m_bufferStats.SetCmd(DVP_FLAG_SKIP_PROC);
-+ }
-+ }
-+
-+ int retval = 0;
-+ uint16_t decoded, processed, render;
-+ Message *msg;
-+ while (m_xvbaOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::ERROR)
-+ {
-+ m_displayState = XVBA_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+ msg->Release();
-+ }
-+
-+ m_bufferStats.Get(decoded, processed, render);
-+
-+ uint64_t startTime = CurrentHostCounter();
-+ while (!retval)
-+ {
-+ if (m_xvbaOutput.m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
-+ {
-+ if (m_presentPicture)
-+ {
-+ m_presentPicture->ReturnUnused();
-+ m_presentPicture = 0;
-+ }
-+
-+ m_presentPicture = *(CXvbaRenderPicture**)msg->data;
-+ m_presentPicture->xvba = this;
-+ m_bufferStats.DecRender();
-+ m_bufferStats.Get(decoded, processed, render);
-+ retval |= VC_PICTURE;
-+ }
-+ msg->Release();
-+ }
-+ else if (m_xvbaOutput.m_controlPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputControlProtocol::STATS)
-+ {
-+ m_bufferStats.Get(decoded, processed, render);
-+ }
-+ else
-+ {
-+ m_displayState = XVBA_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+ msg->Release();
-+ }
-+
-+ if ((m_codecControl & DVP_FLAG_DRAIN))
-+ {
-+ if (decoded + processed + render < 2)
-+ {
-+ retval |= VC_BUFFER;
-+ }
-+ }
-+ else
-+ {
-+ if (decoded + processed + render < 4)
-+ {
-+ retval |= VC_BUFFER;
-+ }
-+ }
-+
-+ if (!retval && !m_inMsgEvent.WaitMSec(2000))
-+ break;
-+ }
-+ uint64_t diff = CurrentHostCounter() - startTime;
-+ if (retval & VC_PICTURE)
-+ {
-+ m_bufferStats.SetParams(diff, m_speed);
-+ if (diff*1000/CurrentHostFrequency() > 50)
-+ CLog::Log(LOGDEBUG,"XVBA::Decode long wait: %d", (int)((diff*1000)/CurrentHostFrequency()));
-+ }
-+
-+ if (!retval)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - timed out waiting for output message", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ retval |= VC_ERROR;
-+ }
-+
-+ return retval;
-+
-+}
-+
-+bool CDecoder::GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture)
-+{
-+ CSingleLock lock(m_decoderSection);
-+
-+ if (m_displayState != XVBA_OPEN)
-+ return false;
-+
-+ *picture = m_presentPicture->DVDPic;
-+ picture->xvba = m_presentPicture;
-+
-+ return true;
-+}
-+
-+void CDecoder::ReturnRenderPicture(CXvbaRenderPicture *renderPic)
-+{
-+ m_xvbaOutput.m_dataPort.SendOutMessage(COutputDataProtocol::RETURNPIC, &renderPic, sizeof(renderPic));
-+}
-+
-+
-+//void CDecoder::CopyYV12(int index, uint8_t *dest)
-+//{
-+// CSharedLock lock(m_decoderSection);
-+//
-+// { CSharedLock dLock(m_displaySection);
-+// if(m_displayState != XVBA_OPEN)
-+// return;
-+// }
-+//
-+// if (!m_flipBuffer[index].outPic)
-+// {
-+// CLog::Log(LOGWARNING, "XVBA::Present: present picture is NULL");
-+// return;
-+// }
-+//
-+// XVBA_GetSurface_Target target;
-+// target.size = sizeof(target);
-+// target.surfaceType = XVBA_YV12;
-+// target.flag = XVBA_FRAME;
-+//
-+// XVBA_Get_Surface_Input input;
-+// input.size = sizeof(input);
-+// input.session = m_xvbaSession;
-+// input.src_surface = m_flipBuffer[index].outPic->render->surface;
-+// input.target_buffer = dest;
-+// input.target_pitch = m_surfaceWidth;
-+// input.target_width = m_surfaceWidth;
-+// input.target_height = m_surfaceHeight;
-+// input.target_parameter = target;
-+// { CSingleLock lock(m_apiSec);
-+// if (Success != g_XVBA_vtable.GetSurface(&input))
-+// {
-+// CLog::Log(LOGERROR,"(XVBA::CopyYV12) failed to get surface");
-+// }
-+// }
-+//}
-+
-+void CDecoder::Reset()
-+{
-+ CSingleLock lock(m_decoderSection);
-+
-+ if (!m_xvbaConfig.xvbaSession)
-+ return;
-+
-+ Message *reply;
-+ if (m_xvbaOutput.m_controlPort.SendOutMessageSync(COutputControlProtocol::FLUSH,
-+ &reply,
-+ 2000))
-+ {
-+ bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
-+ reply->Release();
-+ if (!success)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - flush returned error", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+ else
-+ m_bufferStats.Reset();
-+ }
-+ else
-+ {
-+ CLog::Log(LOGERROR, "XVBA::%s - flush timed out", __FUNCTION__);
-+ m_displayState = XVBA_ERROR;
-+ }
-+}
-+
-+bool CDecoder::CanSkipDeint()
-+{
-+ return m_bufferStats.CanSkipDeint();
-+}
-+
-+void CDecoder::SetSpeed(int speed)
-+{
-+ m_speed = speed;
-+}
-+
-+//-----------------------------------------------------------------------------
-+// RenderPicture
-+//-----------------------------------------------------------------------------
-+
-+CXvbaRenderPicture* CXvbaRenderPicture::Acquire()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ if (refCount == 0)
-+ xvba->Acquire();
-+
-+ refCount++;
-+ return this;
-+}
-+
-+long CXvbaRenderPicture::Release()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ refCount--;
-+ if (refCount > 0)
-+ return refCount;
-+
-+ lock.Leave();
-+ xvba->ReturnRenderPicture(this);
-+ xvba->ReleasePicReference();
-+
-+ return refCount;
-+}
-+
-+void CXvbaRenderPicture::Transfer()
-+{
-+ CSingleLock lock(*renderPicSection);
-+
-+ if (valid)
-+ xvbaOutput->TransferSurface(sourceIdx);
-+}
-+
-+void CXvbaRenderPicture::ReturnUnused()
-+{
-+ { CSingleLock lock(*renderPicSection);
-+ if (refCount > 0)
-+ return;
-+ }
-+ if (xvba)
-+ xvba->ReturnRenderPicture(this);
-+}
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+COutput::COutput(CEvent *inMsgEvent) :
-+ CThread("XVBA Output Thread"),
-+ m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent),
-+ m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent)
-+{
-+ m_inMsgEvent = inMsgEvent;
-+
-+ CXvbaRenderPicture pic;
-+ pic.renderPicSection = &m_bufferPool.renderPicSec;
-+ pic.refCount = 0;
-+ for (unsigned int i = 0; i < NUM_RENDER_PICS; i++)
-+ {
-+ m_bufferPool.allRenderPics.push_back(pic);
-+ }
-+ for (unsigned int i = 0; i < m_bufferPool.allRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.freeRenderPics.push_back(&m_bufferPool.allRenderPics[i]);
-+ }
-+}
-+
-+void COutput::Start()
-+{
-+ Create();
-+}
-+
-+COutput::~COutput()
-+{
-+ Dispose();
-+
-+ m_bufferPool.freeRenderPics.clear();
-+ m_bufferPool.usedRenderPics.clear();
-+ m_bufferPool.allRenderPics.clear();
-+}
-+
-+void COutput::Dispose()
-+{
-+ CSingleLock lock(g_graphicsContext);
-+ m_bStop = true;
-+ m_outMsgEvent.Set();
-+ StopThread();
-+ m_controlPort.Purge();
-+ m_dataPort.Purge();
-+}
-+
-+void COutput::OnStartup()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnStartup: Output Thread created");
-+}
-+
-+void COutput::OnExit()
-+{
-+ CLog::Log(LOGNOTICE, "COutput::OnExit: Output Thread terminated");
-+}
-+
-+enum OUTPUT_STATES
-+{
-+ O_TOP = 0, // 0
-+ O_TOP_ERROR, // 1
-+ O_TOP_UNCONFIGURED, // 2
-+ O_TOP_CONFIGURED, // 3
-+ O_TOP_CONFIGURED_WAIT_RES1, // 4
-+ O_TOP_CONFIGURED_WAIT_DEC, // 5
-+ O_TOP_CONFIGURED_STEP1, // 6
-+ O_TOP_CONFIGURED_WAIT_RES2, // 7
-+ O_TOP_CONFIGURED_STEP2, // 8
-+};
-+
-+int OUTPUT_parentStates[] = {
-+ -1,
-+ 0, //TOP_ERROR
-+ 0, //TOP_UNCONFIGURED
-+ 0, //TOP_CONFIGURED
-+ 3, //TOP_CONFIGURED_WAIT_RES1
-+ 3, //TOP_CONFIGURED_WAIT_DEC
-+ 3, //TOP_CONFIGURED_STEP1
-+ 3, //TOP_CONFIGURED_WAIT_RES2
-+ 3, //TOP_CONFIGURED_STEP2
-+};
-+
-+void COutput::StateMachine(int signal, Protocol *port, Message *msg)
-+{
-+ for (int state = m_state; ; state = OUTPUT_parentStates[state])
-+ {
-+ switch (state)
-+ {
-+ case O_TOP: // TOP
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::RETURNPIC:
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ {
-+ std::string portName = port == NULL ? "timer" : port->portName;
-+ CLog::Log(LOGWARNING, "COutput::%s - signal: %d form port: %s not handled for state: %d", __FUNCTION__, signal, portName.c_str(), m_state);
-+ }
-+ return;
-+
-+ case O_TOP_ERROR:
-+ m_extTimeout = 1000;
-+ break;
-+
-+ case O_TOP_UNCONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::INIT:
-+ CXvbaConfig *data;
-+ data = (CXvbaConfig*)msg->data;
-+ if (data)
-+ {
-+ m_config = *data;
-+ }
-+ Init();
-+ EnsureBufferPool();
-+ if (!m_xvbaError)
-+ {
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ msg->Reply(COutputControlProtocol::ACC);
-+ }
-+ else
-+ {
-+ m_state = O_TOP_ERROR;
-+ msg->Reply(COutputControlProtocol::ERROR);
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED:
-+ if (port == &m_controlPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::FLUSH:
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ Flush();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ case COutputControlProtocol::PRECLEANUP:
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ Flush();
-+ PreReleaseBufferPool();
-+ msg->Reply(COutputControlProtocol::ACC);
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ else if (port == &m_dataPort)
-+ {
-+ switch (signal)
-+ {
-+ case COutputDataProtocol::NEWFRAME:
-+ CXvbaDecodedPicture *frame;
-+ frame = (CXvbaDecodedPicture*)msg->data;
-+ if (frame)
-+ {
-+ m_decodedPics.push(*frame);
-+ m_extTimeout = 0;
-+ }
-+ return;
-+ case COutputDataProtocol::RETURNPIC:
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ m_controlPort.SendInMessage(COutputControlProtocol::STATS);
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WAIT_RES1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (!m_decodedPics.empty() && FindFreeSurface() >= 0 && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ m_state = O_TOP_CONFIGURED_WAIT_DEC;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+ if (m_extTimeout != 0)
-+ {
-+ uint16_t decoded, processed, render;
-+ m_config.stats->Get(decoded, processed, render);
-+// CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render);
-+ }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WAIT_DEC:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (IsDecodingFinished())
-+ {
-+ m_state = O_TOP_CONFIGURED_STEP1;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+ m_extTimeout = 1;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_STEP1:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ m_processPicture = m_decodedPics.front();
-+ m_decodedPics.pop();
-+ InitCycle();
-+ CXvbaRenderPicture *pic;
-+ pic = ProcessPicture();
-+ if (pic)
-+ {
-+ m_config.stats->IncRender();
-+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic));
-+ }
-+ if (m_xvbaError)
-+ {
-+ m_state = O_TOP_ERROR;
-+ return;
-+ }
-+ if (m_deinterlacing && !m_deintSkip)
-+ {
-+ m_state = O_TOP_CONFIGURED_WAIT_RES2;
-+ m_extTimeout = 0;
-+ }
-+ else
-+ {
-+ FiniCycle();
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ m_extTimeout = 0;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_WAIT_RES2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ if (FindFreeSurface() >= 0 && !m_bufferPool.freeRenderPics.empty())
-+ {
-+ m_state = O_TOP_CONFIGURED_STEP2;
-+ m_bStateMachineSelfTrigger = true;
-+ }
-+ else
-+ {
-+ if (m_extTimeout != 0)
-+ {
-+ uint16_t decoded, processed, render;
-+ m_config.stats->Get(decoded, processed, render);
-+ CLog::Log(LOGDEBUG, "CVDPAU::COutput - timeout idle: decoded: %d, proc: %d, render: %d", decoded, processed, render);
-+ }
-+ m_extTimeout = 100;
-+ }
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ case O_TOP_CONFIGURED_STEP2:
-+ if (port == NULL) // timeout
-+ {
-+ switch (signal)
-+ {
-+ case COutputControlProtocol::TIMEOUT:
-+ CXvbaRenderPicture *pic;
-+ m_deintStep = 1;
-+ pic = ProcessPicture();
-+ if (pic)
-+ {
-+ m_config.stats->IncRender();
-+ m_dataPort.SendInMessage(COutputDataProtocol::PICTURE, &pic, sizeof(pic));
-+ }
-+ if (m_xvbaError)
-+ {
-+ m_state = O_TOP_ERROR;
-+ return;
-+ }
-+ FiniCycle();
-+ m_state = O_TOP_CONFIGURED_WAIT_RES1;
-+ m_extTimeout = 0;
-+ return;
-+ default:
-+ break;
-+ }
-+ }
-+ break;
-+
-+ default: // we are in no state, should not happen
-+ CLog::Log(LOGERROR, "COutput::%s - no valid state: %d", __FUNCTION__, m_state);
-+ return;
-+ }
-+ } // for
-+}
-+
-+void COutput::Process()
-+{
-+ Message *msg;
-+ Protocol *port;
-+ bool gotMsg;
-+
-+ m_state = O_TOP_UNCONFIGURED;
-+ m_extTimeout = 1000;
-+ m_bStateMachineSelfTrigger = false;
-+
-+ while (!m_bStop)
-+ {
-+ gotMsg = false;
-+
-+ if (m_bStateMachineSelfTrigger)
-+ {
-+ m_bStateMachineSelfTrigger = false;
-+ // self trigger state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+ // check control port
-+ else if (m_controlPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_controlPort;
-+ }
-+ // check data port
-+ else if (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ gotMsg = true;
-+ port = &m_dataPort;
-+ }
-+ if (gotMsg)
-+ {
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ continue;
-+ }
-+
-+ // wait for message
-+ else if (m_outMsgEvent.WaitMSec(m_extTimeout))
-+ {
-+ continue;
-+ }
-+ // time out
-+ else
-+ {
-+ msg = m_controlPort.GetMessage();
-+ msg->signal = COutputControlProtocol::TIMEOUT;
-+ port = 0;
-+ // signal timeout to state machine
-+ StateMachine(msg->signal, port, msg);
-+ if (!m_bStateMachineSelfTrigger)
-+ {
-+ msg->Release();
-+ msg = NULL;
-+ }
-+ }
-+ }
-+ Flush();
-+ Uninit();
-+}
-+
-+bool COutput::Init()
-+{
-+ if (!CreateGlxContext())
-+ return false;
-+
-+ m_xvbaError = false;
-+ m_processPicture.render = 0;
-+
-+ return true;
-+}
-+
-+bool COutput::Uninit()
-+{
-+ ReleaseBufferPool();
-+ DestroyGlxContext();
-+ return true;
-+}
-+
-+void COutput::Flush()
-+{
-+ while (!m_decodedPics.empty())
-+ {
-+ CXvbaDecodedPicture pic = m_decodedPics.front();
-+ m_decodedPics.pop();
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ }
-+
-+ if (m_processPicture.render)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ m_processPicture.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ m_processPicture.render = 0;
-+ }
-+
-+ Message *msg;
-+ while (m_dataPort.ReceiveOutMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::NEWFRAME)
-+ {
-+ CXvbaDecodedPicture pic = *(CXvbaDecodedPicture*)msg->data;
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ if (pic.render)
-+ pic.render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ }
-+ else if (msg->signal == COutputDataProtocol::RETURNPIC)
-+ {
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ msg->Release();
-+ }
-+
-+ while (m_dataPort.ReceiveInMessage(&msg))
-+ {
-+ if (msg->signal == COutputDataProtocol::PICTURE)
-+ {
-+ CXvbaRenderPicture *pic;
-+ pic = *((CXvbaRenderPicture**)msg->data);
-+ ProcessReturnPicture(pic);
-+ }
-+ }
-+}
-+
-+bool COutput::IsDecodingFinished()
-+{
-+ return true;
-+
-+ // check for decoding to be finished
-+ CXvbaDecodedPicture decodedPic = m_decodedPics.front();
-+
-+ XVBA_Surface_Sync_Input syncInput;
-+ XVBA_Surface_Sync_Output syncOutput;
-+ syncInput.size = sizeof(syncInput);
-+ syncInput.session = m_config.xvbaSession;
-+ syncInput.surface = decodedPic.render->surface;
-+ syncInput.query_status = XVBA_GET_SURFACE_STATUS;
-+ syncOutput.size = sizeof(syncOutput);
-+ { CSingleLock lock(*(m_config.apiSec));
-+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput))
-+ {
-+ CLog::Log(LOGERROR,"XVBA - failed sync surface");
-+ m_xvbaError = true;
-+ return false;
-+ }
-+ }
-+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING))
-+ return true;
-+
-+ return false;
-+}
-+
-+void COutput::TransferSurface(uint32_t source)
-+{
-+ XvbaBufferPool::GLVideoSurface *glSurface = &m_bufferPool.glSurfaces[source];
-+
-+ if (glSurface->transferred)
-+ return;
-+
-+ glSurface->transferred = true;
-+
-+ // transfer surface
-+ XVBA_Transfer_Surface_Input transInput;
-+ transInput.size = sizeof(transInput);
-+ transInput.session = m_config.xvbaSession;
-+ transInput.src_surface = glSurface->render->surface;
-+ transInput.target_surface = glSurface->glSurface;
-+ transInput.flag = glSurface->field;
-+ { CSingleLock lock(*(m_config.apiSec));
-+ if (Success != g_XVBA_vtable.TransferSurface(&transInput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) failed to transfer surface");
-+ m_xvbaError = true;
-+ return;
-+ }
-+ }
-+}
-+
-+CXvbaRenderPicture* COutput::ProcessPicture()
-+{
-+ CXvbaRenderPicture *retPic = 0;
-+
-+ if (m_deintStep == 1)
-+ {
-+ if(m_field == XVBA_TOP_FIELD)
-+ m_field = XVBA_BOTTOM_FIELD;
-+ else
-+ m_field = XVBA_TOP_FIELD;
-+ }
-+
-+ // find unused shared surface
-+ unsigned int idx = FindFreeSurface();
-+ XvbaBufferPool::GLVideoSurface *glSurface = &m_bufferPool.glSurfaces[idx];
-+ glSurface->used = true;
-+ glSurface->field = m_field;
-+ glSurface->render = m_processPicture.render;
-+ glSurface->transferred = false;
-+
-+ int cmd = 0;
-+ m_config.stats->GetCmd(cmd);
-+
-+// if (!(cmd & DVP_FLAG_SKIP_PROC))
-+// {
-+ // transfer surface
-+ XVBA_Transfer_Surface_Input transInput;
-+ transInput.size = sizeof(transInput);
-+ transInput.session = m_config.xvbaSession;
-+ transInput.src_surface = m_processPicture.render->surface;
-+ transInput.target_surface = glSurface->glSurface;
-+ transInput.flag = m_field;
-+ { CSingleLock lock(*(m_config.apiSec));
-+ if (Success != g_XVBA_vtable.TransferSurface(&transInput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) failed to transfer surface");
-+ m_xvbaError = true;
-+ return retPic;
-+ }
-+ }
-+
-+ // make sure that transfer is completed
-+// uint64_t maxTimeout = 1000000000LL;
-+// GLsync ReadyFence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
-+// glClientWaitSync(ReadyFence, GL_SYNC_FLUSH_COMMANDS_BIT, maxTimeout);
-+// glDeleteSync(ReadyFence);
-+// glFinish();GL_SYNC_FLUSH_COMMANDS_BIT
-+// }
-+// else
-+// {
-+// CLog::Log(LOGDEBUG,"XVBA::ProcessPicture - skipped transfer surface");
-+// m_processPicture.DVDPic.iFlags |= DVP_FLAG_DROPPED;
-+// }
-+
-+ // prepare render pic
-+ retPic = m_bufferPool.freeRenderPics.front();
-+ m_bufferPool.freeRenderPics.pop_front();
-+ m_bufferPool.usedRenderPics.push_back(retPic);
-+ retPic->sourceIdx = glSurface->id;
-+ retPic->DVDPic = m_processPicture.DVDPic;
-+ retPic->valid = true;
-+ retPic->texture = glSurface->texture;
-+ retPic->crop = CRect(0,0,0,0);
-+ retPic->texWidth = m_config.surfaceWidth;
-+ retPic->texHeight = m_config.surfaceHeight;
-+ retPic->xvbaOutput = this;
-+
-+ // set repeat pic for de-interlacing
-+ if (m_deinterlacing)
-+ {
-+ if (m_deintStep == 1)
-+ {
-+ retPic->DVDPic.pts = DVD_NOPTS_VALUE;
-+ retPic->DVDPic.dts = DVD_NOPTS_VALUE;
-+ }
-+ retPic->DVDPic.iRepeatPicture = 0.0;
-+ }
-+
-+ return retPic;
-+}
-+
-+void COutput::ProcessReturnPicture(CXvbaRenderPicture *pic)
-+{
-+ std::deque::iterator it;
-+ it = std::find(m_bufferPool.usedRenderPics.begin(), m_bufferPool.usedRenderPics.end(), pic);
-+ if (it == m_bufferPool.usedRenderPics.end())
-+ {
-+ CLog::Log(LOGWARNING, "COutput::ProcessReturnPicture - pic not found");
-+ return;
-+ }
-+ m_bufferPool.usedRenderPics.erase(it);
-+ m_bufferPool.freeRenderPics.push_back(pic);
-+ if (!pic->valid)
-+ {
-+ CLog::Log(LOGDEBUG, "COutput::%s - return of invalid render pic", __FUNCTION__);
-+ return;
-+ }
-+
-+ if (m_config.useSharedSurfaces)
-+ {
-+ xvba_render_state *render = m_bufferPool.glSurfaces[pic->sourceIdx].render;
-+ if (render)
-+ {
-+ // check if video surface if referenced by other glSurfaces
-+ bool referenced(false);
-+ for (unsigned int i=0; isourceIdx)
-+ continue;
-+ if (m_bufferPool.glSurfaces[i].render == render)
-+ {
-+ referenced = true;
-+ break;
-+ }
-+ }
-+ if (m_processPicture.render == render)
-+ referenced = true;
-+
-+ // release video surface
-+ if (!referenced)
-+ {
-+ CSingleLock lock(*m_config.videoSurfaceSec);
-+ render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ }
-+
-+ // unreference video surface
-+ m_bufferPool.glSurfaces[pic->sourceIdx].render = 0;
-+ }
-+ m_bufferPool.glSurfaces[pic->sourceIdx].used = false;
-+ return;
-+ }
-+}
-+
-+int COutput::FindFreeSurface()
-+{
-+ // find free shared surface
-+ unsigned int i;
-+ for (i = 0; i < m_bufferPool.glSurfaces.size(); ++i)
-+ {
-+ if (!m_bufferPool.glSurfaces[i].used)
-+ break;
-+ }
-+ if (i == m_bufferPool.glSurfaces.size())
-+ return -1;
-+ else
-+ return i;
-+}
-+
-+void COutput::InitCycle()
-+{
-+ uint64_t latency;
-+ int speed;
-+ m_config.stats->GetParams(latency, speed);
-+ latency = (latency*1000)/CurrentHostFrequency();
-+
-+ m_config.stats->SetCanSkipDeint(false);
-+
-+ EDEINTERLACEMODE mode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
-+ EINTERLACEMETHOD method = g_settings.m_currentVideoSettings.m_InterlaceMethod;
-+ bool interlaced = m_processPicture.DVDPic.iFlags & DVP_FLAG_INTERLACED;
-+
-+ if (mode == VS_DEINTERLACEMODE_FORCE ||
-+ (mode == VS_DEINTERLACEMODE_AUTO && interlaced))
-+ {
-+ if((method == VS_INTERLACEMETHOD_AUTO && interlaced)
-+ || method == VS_INTERLACEMETHOD_XVBA)
-+ {
-+ m_deinterlacing = true;
-+ m_deintSkip = false;
-+ m_config.stats->SetCanSkipDeint(true);
-+
-+ if (m_processPicture.DVDPic.iFlags & DVP_FLAG_DROPDEINT)
-+ {
-+ m_deintSkip = true;
-+ }
-+
-+ // do only half deinterlacing
-+ if (speed != DVD_PLAYSPEED_NORMAL || !g_graphicsContext.IsFullScreenVideo())
-+ {
-+ m_config.stats->SetCanSkipDeint(false);
-+ m_deintSkip = true;
-+ }
-+
-+ if(m_processPicture.DVDPic.iFlags & DVP_FLAG_TOP_FIELD_FIRST)
-+ m_field = XVBA_TOP_FIELD;
-+ else
-+ m_field = XVBA_BOTTOM_FIELD;
-+ }
-+ }
-+ else
-+ {
-+ m_deinterlacing = false;
-+ m_field = XVBA_FRAME;
-+ }
-+
-+ m_processPicture.DVDPic.format = DVDVideoPicture::FMT_XVBA;
-+ m_processPicture.DVDPic.iFlags &= ~(DVP_FLAG_TOP_FIELD_FIRST |
-+ DVP_FLAG_REPEAT_TOP_FIELD |
-+ DVP_FLAG_INTERLACED);
-+ m_processPicture.DVDPic.iWidth = m_config.vidWidth;
-+ m_processPicture.DVDPic.iHeight = m_config.vidHeight;
-+
-+ m_deintStep = 0;
-+}
-+
-+void COutput::FiniCycle()
-+{
-+// { CSingleLock lock(*m_config.videoSurfaceSec);
-+// m_processPicture.render->state &= ~FF_XVBA_STATE_USED_FOR_RENDER;
-+// }
-+ m_processPicture.render = 0;
-+ m_config.stats->DecDecoded();
-+}
-+
-+bool COutput::EnsureBufferPool()
-+{
-+ if (m_config.useSharedSurfaces && m_bufferPool.glSurfaces.empty())
-+ {
-+ GLenum textureTarget;
-+ if (!glewIsSupported("GL_ARB_texture_non_power_of_two") && glewIsSupported("GL_ARB_texture_rectangle"))
-+ {
-+ textureTarget = GL_TEXTURE_RECTANGLE_ARB;
-+ }
-+ else
-+ textureTarget = GL_TEXTURE_2D;
-+
-+ // create shared surfaces
-+ XvbaBufferPool::GLVideoSurface surface;
-+ for (unsigned int i = 0; i < NUM_RENDER_PICS; ++i)
-+ {
-+ glEnable(textureTarget);
-+ glGenTextures(1, &surface.texture);
-+ glBindTexture(textureTarget, surface.texture);
-+ glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-+ glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-+ glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
-+ glTexImage2D(textureTarget, 0, GL_RGBA, m_config.surfaceWidth, m_config.surfaceHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
-+
-+ XVBA_Create_GLShared_Surface_Input surfInput;
-+ XVBA_Create_GLShared_Surface_Output surfOutput;
-+ surfInput.size = sizeof(surfInput);
-+ surfInput.session = m_config.xvbaSession;
-+ surfInput.gltexture = surface.texture;
-+ surfInput.glcontext = m_glContext;
-+ surfOutput.size = sizeof(surfOutput);
-+ surfOutput.surface = 0;
-+ if (Success != g_XVBA_vtable.CreateGLSharedSurface(&surfInput, &surfOutput))
-+ {
-+ CLog::Log(LOGERROR,"(XVBA) failed to create shared surface");
-+ m_xvbaError = true;
-+ break;
-+ }
-+ CLog::Log(LOGDEBUG, "XVBA::GetTexture - created shared surface");
-+
-+ surface.glSurface = surfOutput.surface;
-+ surface.id = i;
-+ surface.used = false;
-+ surface.render = 0;
-+ m_bufferPool.glSurfaces.push_back(surface);
-+ }
-+ glDisable(textureTarget);
-+ }
-+
-+ return true;
-+}
-+
-+void COutput::ReleaseBufferPool()
-+{
-+ CSingleLock lock(m_bufferPool.renderPicSec);
-+
-+ if (m_config.useSharedSurfaces)
-+ {
-+ for (unsigned int i = 0; i < m_bufferPool.glSurfaces.size(); ++i)
-+ {
-+ if (!m_bufferPool.glSurfaces[i].glSurface)
-+ continue;
-+ g_XVBA_vtable.DestroySurface(m_bufferPool.glSurfaces[i].glSurface);
-+ glDeleteTextures(1, &m_bufferPool.glSurfaces[i].texture);
-+ }
-+ m_bufferPool.glSurfaces.clear();
-+ }
-+ // invalidate all used render pictures
-+ for (unsigned int i = 0; i < m_bufferPool.usedRenderPics.size(); ++i)
-+ {
-+ m_bufferPool.usedRenderPics[i]->valid = false;
-+ unsigned int idx = m_bufferPool.usedRenderPics[i]->sourceIdx;
-+ if (m_bufferPool.glSurfaces[idx].render)
-+ {
-+ { CSingleLock lock(*m_config.videoSurfaceSec);
-+ m_bufferPool.glSurfaces[idx].render->state &= ~(FF_XVBA_STATE_USED_FOR_RENDER | FF_XVBA_STATE_DECODED);
-+ m_bufferPool.glSurfaces[idx].render = 0;
-+ }
-+ }
-+ }
-+}
-+
-+void COutput::PreReleaseBufferPool()
-+{
-+ CSingleLock lock(m_bufferPool.renderPicSec);
-+
-+ if (m_config.useSharedSurfaces)
-+ {
-+ for (unsigned int i = 0; i < m_bufferPool.glSurfaces.size(); ++i)
-+ {
-+ if (!m_bufferPool.glSurfaces[i].used)
-+ {
-+ g_XVBA_vtable.DestroySurface(m_bufferPool.glSurfaces[i].glSurface);
-+ glDeleteTextures(1, &m_bufferPool.glSurfaces[i].texture);
-+ m_bufferPool.glSurfaces[i].glSurface = 0;
-+ m_bufferPool.glSurfaces[i].used = true;
-+ }
-+ }
-+ }
-+}
-+
-+bool COutput::CreateGlxContext()
-+{
-+ GLXContext glContext;
-+ Window window;
-+
-+ m_Display = g_Windowing.GetDisplay();
-+ glContext = g_Windowing.GetGlxContext();
-+ m_Window = g_Windowing.GetWmWindow();
-+
-+ // Get our window attribs.
-+ XWindowAttributes wndattribs;
-+ XGetWindowAttributes(m_Display, m_Window, &wndattribs);
-+
-+ // Get visual Info
-+ XVisualInfo visInfo;
-+ visInfo.visualid = wndattribs.visual->visualid;
-+ int nvisuals = 0;
-+ XVisualInfo* visuals = XGetVisualInfo(m_Display, VisualIDMask, &visInfo, &nvisuals);
-+ if (nvisuals != 1)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::COutput::CreateGlxContext - could not find visual");
-+ return false;
-+ }
-+ visInfo = visuals[0];
-+ XFree(visuals);
-+
-+ m_pixmap = XCreatePixmap(m_Display,
-+ DefaultRootWindow(m_Display),
-+ 192,
-+ 108,
-+ visInfo.depth);
-+ if (!m_pixmap)
-+ {
-+ CLog::Log(LOGERROR, "XVBA::COutput::CreateGlxContext - Unable to create XPixmap");
-+ return false;
-+ }
-+
-+ // create gl pixmap
-+ m_glPixmap = glXCreateGLXPixmap(m_Display, &visInfo, m_pixmap);
-+
-+ if (!m_glPixmap)
-+ {
-+ CLog::Log(LOGINFO, "XVBA::COutput::CreateGlxContext - Could not create glPixmap");
-+ return false;
-+ }
-+
-+ m_glContext = glXCreateContext(m_Display, &visInfo, glContext, True);
-+
-+ if (!glXMakeCurrent(m_Display, m_glPixmap, m_glContext))
-+ {
-+ CLog::Log(LOGINFO, "XVBA::COutput::CreateGlxContext - Could not make Pixmap current");
-+ return false;
-+ }
-+
-+ CLog::Log(LOGNOTICE, "XVBA::COutput::CreateGlxContext - created context");
-+ return true;
-+}
-+
-+bool COutput::DestroyGlxContext()
-+{
-+ if (m_glContext)
-+ {
-+ glXMakeCurrent(m_Display, None, NULL);
-+ glXDestroyContext(m_Display, m_glContext);
-+ }
-+ m_glContext = 0;
-+
-+ if (m_glPixmap)
-+ glXDestroyPixmap(m_Display, m_glPixmap);
-+ m_glPixmap = 0;
-+
-+ if (m_pixmap)
-+ XFreePixmap(m_Display, m_pixmap);
-+ m_pixmap = 0;
-+
-+ return true;
-+}
-+
-+#endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h 2012-05-14 14:15:12.137220527 +0200
-@@ -0,0 +1,386 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+#pragma once
-+
-+#include "X11/Xlib.h"
-+#include "amd/amdxvba.h"
-+#include "DllAvCodec.h"
-+#include "DVDCodecs/Video/DVDVideoCodecFFmpeg.h"
-+#include "threads/Thread.h"
-+#include "threads/CriticalSection.h"
-+#include "threads/SharedSection.h"
-+#include "threads/Event.h"
-+#include "guilib/DispResource.h"
-+#include "guilib/Geometry.h"
-+#include "libavcodec/xvba.h"
-+#include "utils/ActorProtocol.h"
-+#include "settings/VideoSettings.h"
-+#include
-+#include
-+#include
-+#include
-+
-+using namespace Actor;
-+
-+
-+namespace XVBA
-+{
-+
-+//-----------------------------------------------------------------------------
-+// XVBA data structs
-+//-----------------------------------------------------------------------------
-+
-+class CDecoder;
-+class CXVBAContext;
-+class COutput;
-+
-+#define NUM_RENDER_PICS 9
-+
-+/**
-+ * Buffer statistics used to control number of frames in queue
-+ */
-+
-+class CXvbaBufferStats
-+{
-+public:
-+ uint16_t decodedPics;
-+ uint16_t processedPics;
-+ uint16_t renderPics;
-+ uint64_t latency; // time decoder has waited for a frame, ideally there is no latency
-+ int playSpeed;
-+ bool canSkipDeint;
-+ int processCmd;
-+
-+ void IncDecoded() { CSingleLock l(m_sec); decodedPics++;}
-+ void DecDecoded() { CSingleLock l(m_sec); decodedPics--;}
-+ void IncProcessed() { CSingleLock l(m_sec); processedPics++;}
-+ void DecProcessed() { CSingleLock l(m_sec); processedPics--;}
-+ void IncRender() { CSingleLock l(m_sec); renderPics++;}
-+ void DecRender() { CSingleLock l(m_sec); renderPics--;}
-+ void Reset() { CSingleLock l(m_sec); decodedPics=0; processedPics=0;renderPics=0;latency=0;}
-+ void Get(uint16_t &decoded, uint16_t &processed, uint16_t &render) {CSingleLock l(m_sec); decoded = decodedPics, processed=processedPics, render=renderPics;}
-+ void SetParams(uint64_t time, int speed) { CSingleLock l(m_sec); latency = time; playSpeed = speed; }
-+ void GetParams(uint64_t &lat, int &speed) { CSingleLock l(m_sec); lat = latency; speed = playSpeed; }
-+ void SetCmd(int cmd) { CSingleLock l(m_sec); processCmd = cmd; }
-+ void GetCmd(int &cmd) { CSingleLock l(m_sec); cmd = processCmd; processCmd = 0; }
-+ void SetCanSkipDeint(bool canSkip) { CSingleLock l(m_sec); canSkipDeint = canSkip; }
-+ bool CanSkipDeint() { CSingleLock l(m_sec); if (canSkipDeint) return true; else return false;}
-+private:
-+ CCriticalSection m_sec;
-+};
-+
-+/**
-+ * CXvbaConfig holds all configuration parameters needed by vdpau
-+ * The structure is sent to the internal classes CMixer and COutput
-+ * for init.
-+ */
-+
-+struct CXvbaConfig
-+{
-+ int surfaceWidth;
-+ int surfaceHeight;
-+ int vidWidth;
-+ int vidHeight;
-+ int outWidth;
-+ int outHeight;
-+ bool useSharedSurfaces;
-+
-+ CXVBAContext *context;
-+ XVBADecodeCap decoderCap;
-+ void *xvbaSession;
-+ std::vector *videoSurfaces;
-+ CCriticalSection *videoSurfaceSec;
-+ CCriticalSection *apiSec;
-+
-+ CXvbaBufferStats *stats;
-+ int numRenderBuffers;
-+ uint32_t maxReferences;
-+};
-+
-+/**
-+ * Holds a decoded frame
-+ * Input to COutput for further processing
-+ */
-+struct CXvbaDecodedPicture
-+{
-+ DVDVideoPicture DVDPic;
-+ xvba_render_state *render;
-+};
-+
-+/**
-+ * Ready to render textures
-+ * Sent from COutput back to CDecoder
-+ * Objects are referenced by DVDVideoPicture and are sent
-+ * to renderer
-+ */
-+class CXvbaRenderPicture
-+{
-+ friend class CDecoder;
-+ friend class COutput;
-+public:
-+ DVDVideoPicture DVDPic;
-+ int texWidth, texHeight;
-+ CRect crop;
-+ GLuint texture;
-+ uint32_t sourceIdx;
-+ bool valid;
-+ CDecoder *xvba;
-+ CXvbaRenderPicture* Acquire();
-+ long Release();
-+ void Transfer();
-+private:
-+ void ReturnUnused();
-+ int refCount;
-+ CCriticalSection *renderPicSection;
-+ COutput *xvbaOutput;
-+};
-+
-+//-----------------------------------------------------------------------------
-+// Output
-+//-----------------------------------------------------------------------------
-+
-+/**
-+ * Buffer pool holds allocated xvba and gl resources
-+ * Embedded in COutput
-+ */
-+struct XvbaBufferPool
-+{
-+ struct GLVideoSurface
-+ {
-+ unsigned int id;
-+ bool used;
-+ bool transferred;
-+ GLuint texture;
-+ void *glSurface;
-+ xvba_render_state *render;
-+ XVBA_SURFACE_FLAG field;
-+ };
-+ std::vector glSurfaces;
-+ std::vector allRenderPics;
-+ std::deque usedRenderPics;
-+ std::deque freeRenderPics;
-+ CCriticalSection renderPicSec;
-+};
-+
-+class COutputControlProtocol : public Protocol
-+{
-+public:
-+ COutputControlProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ INIT,
-+ FLUSH,
-+ PRECLEANUP,
-+ TIMEOUT,
-+ };
-+ enum InSignal
-+ {
-+ ACC,
-+ ERROR,
-+ STATS,
-+ };
-+};
-+
-+class COutputDataProtocol : public Protocol
-+{
-+public:
-+ COutputDataProtocol(std::string name, CEvent* inEvent, CEvent *outEvent) : Protocol(name, inEvent, outEvent) {};
-+ enum OutSignal
-+ {
-+ NEWFRAME = 0,
-+ RETURNPIC,
-+ };
-+ enum InSignal
-+ {
-+ PICTURE,
-+ };
-+};
-+
-+/**
-+ * COutput is embedded in CDecoder and embeds CMixer
-+ * The class has its own OpenGl context which is shared with render thread
-+ * COuput generated ready to render textures and passes them back to
-+ * CDecoder
-+ */
-+class COutput : private CThread
-+{
-+public:
-+ COutput(CEvent *inMsgEvent);
-+ virtual ~COutput();
-+ void Start();
-+ void Dispose();
-+ void TransferSurface(uint32_t source);
-+ COutputControlProtocol m_controlPort;
-+ COutputDataProtocol m_dataPort;
-+protected:
-+ void OnStartup();
-+ void OnExit();
-+ void Process();
-+ void StateMachine(int signal, Protocol *port, Message *msg);
-+ bool HasWork();
-+ bool IsDecodingFinished();
-+ CXvbaRenderPicture* ProcessPicture();
-+ void ProcessReturnPicture(CXvbaRenderPicture *pic);
-+ int FindFreeSurface();
-+ void InitCycle();
-+ void FiniCycle();
-+ bool Init();
-+ bool Uninit();
-+ void Flush();
-+ bool CreateGlxContext();
-+ bool DestroyGlxContext();
-+ bool EnsureBufferPool();
-+ void ReleaseBufferPool();
-+ void PreReleaseBufferPool();
-+ CEvent m_outMsgEvent;
-+ CEvent *m_inMsgEvent;
-+ int m_state;
-+ bool m_bStateMachineSelfTrigger;
-+
-+ // extended state variables for state machine
-+ int m_extTimeout;
-+ bool m_xvbaError;
-+ CXvbaConfig m_config;
-+ XvbaBufferPool m_bufferPool;
-+ Display *m_Display;
-+ Window m_Window;
-+ GLXContext m_glContext;
-+ GLXWindow m_glWindow;
-+ Pixmap m_pixmap;
-+ GLXPixmap m_glPixmap;
-+ std::queue m_decodedPics;
-+ CXvbaDecodedPicture m_processPicture;
-+ XVBA_SURFACE_FLAG m_field;
-+ bool m_deinterlacing;
-+ int m_deintStep;
-+ bool m_deintSkip;
-+};
-+
-+//-----------------------------------------------------------------------------
-+// XVBA decoder
-+//-----------------------------------------------------------------------------
-+
-+class CXVBAContext
-+{
-+public:
-+ static bool EnsureContext(CXVBAContext **ctx);
-+ void *GetContext();
-+ void Release();
-+private:
-+ CXVBAContext();
-+ void Close();
-+ bool LoadSymbols();
-+ bool CreateContext();
-+ void DestroyContext();
-+ static CXVBAContext *m_context;
-+ static CCriticalSection m_section;
-+ static Display *m_display;
-+ int m_refCount;
-+ static void *m_dlHandle;
-+ void *m_xvbaContext;
-+};
-+
-+class CDecoder : public CDVDVideoCodecFFmpeg::IHardwareDecoder,
-+ public IDispResource
-+{
-+ friend class CXvbaRenderPicture;
-+
-+public:
-+
-+ struct pictureAge
-+ {
-+ int b_age;
-+ int ip_age[2];
-+ };
-+
-+ enum EDisplayState
-+ { XVBA_OPEN
-+ , XVBA_RESET
-+ , XVBA_LOST
-+ , XVBA_ERROR
-+ };
-+
-+ CDecoder();
-+ virtual ~CDecoder();
-+ virtual void OnLostDevice();
-+ virtual void OnResetDevice();
-+
-+ virtual bool Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned int surfaces = 0);
-+ virtual int Decode (AVCodecContext* avctx, AVFrame* frame);
-+ virtual bool GetPicture(AVCodecContext* avctx, AVFrame* frame, DVDVideoPicture* picture);
-+ virtual void Reset();
-+ virtual void Close();
-+ virtual int Check(AVCodecContext* avctx);
-+ virtual long Release();
-+ virtual const std::string Name() { return "xvba"; }
-+ virtual bool CanSkipDeint();
-+ virtual void SetSpeed(int speed);
-+
-+ bool Supports(EINTERLACEMETHOD method);
-+ long ReleasePicReference();
-+
-+protected:
-+ bool CreateSession(AVCodecContext* avctx);
-+ void DestroySession();
-+ bool EnsureDataControlBuffers(unsigned int num);
-+ void ResetState();
-+ void SetError(const char* function, const char* msg, int line);
-+ bool IsSurfaceValid(xvba_render_state *render);
-+ void ReturnRenderPicture(CXvbaRenderPicture *renderPic);
-+
-+ // callbacks for ffmpeg
-+ static void FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic);
-+ static void FFDrawSlice(struct AVCodecContext *avctx,
-+ const AVFrame *src, int offset[4],
-+ int y, int type, int height);
-+ static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
-+
-+ DllAvUtil m_dllAvUtil;
-+ CCriticalSection m_decoderSection;
-+ CEvent m_displayEvent;
-+ EDisplayState m_displayState;
-+ CXvbaConfig m_xvbaConfig;
-+ std::vector m_videoSurfaces;
-+ CCriticalSection m_apiSec, m_videoSurfaceSec;
-+ ThreadIdentifier m_decoderThread;
-+
-+ unsigned int m_decoderId;
-+ struct XVBABufferPool
-+ {
-+ XVBABufferDescriptor *picture_descriptor_buffer;
-+ XVBABufferDescriptor *iq_matrix_buffer;
-+ XVBABufferDescriptor *data_buffer;
-+ std::vector data_control_buffers;
-+ };
-+ XVBABufferPool m_xvbaBufferPool;
-+
-+ pictureAge picAge;
-+
-+ COutput m_xvbaOutput;
-+ CXvbaBufferStats m_bufferStats;
-+ CEvent m_inMsgEvent;
-+ CXvbaRenderPicture *m_presentPicture;
-+
-+ int m_speed;
-+ int m_codecControl;
-+};
-+
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-05-14 14:11:52.793931617 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp 2012-05-14 14:35:25.789526441 +0200
-@@ -19,7 +19,6 @@
- *
- */
-
--#include "threads/SystemClock.h"
- #include "system.h"
- #ifndef __STDC_CONSTANT_MACROS
- #define __STDC_CONSTANT_MACROS
-@@ -44,6 +43,7 @@
- #include "filesystem/Directory.h"
- #include "utils/log.h"
- #include "threads/Thread.h"
-+#include "threads/SystemClock.h"
- #include "utils/TimeUtils.h"
-
- void CDemuxStreamAudioFFmpeg::GetStreamInfo(std::string& strInfo)
-@@ -154,16 +154,12 @@
- ++it;
- }
-
--#ifdef _MSC_VER
--static __declspec(thread) CDVDDemuxFFmpeg* g_demuxer = 0;
--#else
--static TLS g_tls;
--#define g_demuxer (*((CDVDDemuxFFmpeg**)g_tls.Get()))
--#endif
-+static XbmcThreads::ThreadLocal g_demuxer;
-
- static int interrupt_cb(void* unused)
- {
-- if(g_demuxer && g_demuxer->Aborted())
-+ CDVDDemuxFFmpeg* demuxer = g_demuxer.get();
-+ if(demuxer && demuxer->Aborted())
- return 1;
- return 0;
- }
-@@ -235,7 +231,7 @@
- std::string strFile;
- m_iCurrentPts = DVD_NOPTS_VALUE;
- m_speed = DVD_PLAYSPEED_NORMAL;
-- g_demuxer = this;
-+ g_demuxer.set(this);
- m_program = UINT_MAX;
- const AVIOInterruptCB int_cb = { interrupt_cb, NULL };
-
-@@ -499,7 +495,7 @@
-
- void CDVDDemuxFFmpeg::Dispose()
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- if (m_pFormatContext)
- {
-@@ -540,7 +536,7 @@
-
- void CDVDDemuxFFmpeg::Flush()
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- // naughty usage of an internal ffmpeg function
- if (m_pFormatContext)
-@@ -556,7 +552,7 @@
-
- void CDVDDemuxFFmpeg::SetSpeed(int iSpeed)
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- if(!m_pFormatContext)
- return;
-@@ -618,7 +614,7 @@
-
- DemuxPacket* CDVDDemuxFFmpeg::Read()
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- AVPacket pkt;
- DemuxPacket* pPacket = NULL;
-@@ -810,7 +806,7 @@
-
- bool CDVDDemuxFFmpeg::SeekTime(int time, bool backwords, double *startpts)
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- if(time < 0)
- time = 0;
-@@ -870,7 +866,7 @@
-
- bool CDVDDemuxFFmpeg::SeekByte(__int64 pos)
- {
-- g_demuxer = this;
-+ g_demuxer.set(this);
-
- CSingleLock lock(m_critSection);
- int ret = m_dllAvFormat.av_seek_frame(m_pFormatContext, -1, pos, AVSEEK_FLAG_BYTE);
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.cpp 2012-05-14 14:15:12.140220588 +0200
-@@ -21,6 +21,7 @@
-
- #include "DVDPerformanceCounter.h"
- #include "DVDMessageQueue.h"
-+#include "utils/TimeUtils.h"
-
- #include "dvd_config.h"
-
-@@ -68,22 +69,16 @@
-
- inline __int64 get_thread_cpu_usage(ProcessPerformance* p)
- {
-- if (p->hThread)
-+ if (p->thread)
- {
-- FILETIME dummy;
-- FILETIME current_time_thread;
-- FILETIME current_time_system;
- ULARGE_INTEGER old_time_thread;
- ULARGE_INTEGER old_time_system;
-
- old_time_thread.QuadPart = p->timer_thread.QuadPart;
- old_time_system.QuadPart = p->timer_system.QuadPart;
-
-- GetThreadTimes(p->hThread, &dummy, &dummy, ¤t_time_thread, &dummy);
-- GetSystemTimeAsFileTime(¤t_time_system);
--
-- FILETIME_TO_ULARGE_INTEGER(p->timer_thread, current_time_thread);
-- FILETIME_TO_ULARGE_INTEGER(p->timer_system, current_time_system);
-+ p->timer_thread.QuadPart = p->thread->GetAbsoluteUsage();
-+ p->timer_system.QuadPart = CurrentHostCounter();
-
- __int64 threadTime = (p->timer_thread.QuadPart - old_time_thread.QuadPart);
- __int64 systemTime = (p->timer_system.QuadPart - old_time_system.QuadPart);
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPerformanceCounter.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPerformanceCounter.h 2012-05-14 14:15:12.141220608 +0200
-@@ -24,7 +24,7 @@
- #define FILETIME_TO_ULARGE_INTEGER(ularge, filetime) { ularge.u.HighPart = filetime.dwHighDateTime; ularge.u.LowPart = filetime.dwLowDateTime; }
-
- #include "system.h"
--
-+#include "threads/Thread.h"
- #include "threads/SingleLock.h"
-
- class CDVDMessageQueue;
-@@ -33,7 +33,7 @@
- {
- ULARGE_INTEGER timer_thread;
- ULARGE_INTEGER timer_system;
-- HANDLE hThread;
-+ CThread* thread;
- } ProcessPerformance;
-
- class CDVDPerformanceCounter
-@@ -45,20 +45,20 @@
- bool Initialize();
- void DeInitialize();
-
-- void EnableAudioQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pAudioQueue = pQueue; }
-- void DisableAudioQueue() { CSingleLock lock(m_critSection); m_pAudioQueue = NULL; }
-+ void EnableAudioQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pAudioQueue = pQueue; }
-+ void DisableAudioQueue() { CSingleLock lock(m_critSection); m_pAudioQueue = NULL; }
-
-- void EnableVideoQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pVideoQueue = pQueue; }
-- void DisableVideoQueue() { CSingleLock lock(m_critSection); m_pVideoQueue = NULL; }
-+ void EnableVideoQueue(CDVDMessageQueue* pQueue) { CSingleLock lock(m_critSection); m_pVideoQueue = pQueue; }
-+ void DisableVideoQueue() { CSingleLock lock(m_critSection); m_pVideoQueue = NULL; }
-
-- void EnableVideoDecodePerformance(HANDLE hThread) { CSingleLock lock(m_critSection); m_videoDecodePerformance.hThread = hThread; }
-- void DisableVideoDecodePerformance() { CSingleLock lock(m_critSection); m_videoDecodePerformance.hThread = NULL; }
-+ void EnableVideoDecodePerformance(CThread *thread) { CSingleLock lock(m_critSection); m_videoDecodePerformance.thread = thread; }
-+ void DisableVideoDecodePerformance() { CSingleLock lock(m_critSection); m_videoDecodePerformance.thread = NULL; }
-
-- void EnableAudioDecodePerformance(HANDLE hThread) { CSingleLock lock(m_critSection); m_audioDecodePerformance.hThread = hThread; }
-- void DisableAudioDecodePerformance() { CSingleLock lock(m_critSection); m_audioDecodePerformance.hThread = NULL; }
-+ void EnableAudioDecodePerformance(CThread *thread) { CSingleLock lock(m_critSection); m_audioDecodePerformance.thread = thread; }
-+ void DisableAudioDecodePerformance() { CSingleLock lock(m_critSection); m_audioDecodePerformance.thread = NULL; }
-
-- void EnableMainPerformance(HANDLE hThread) { CSingleLock lock(m_critSection); m_mainPerformance.hThread = hThread; }
-- void DisableMainPerformance() { CSingleLock lock(m_critSection); m_mainPerformance.hThread = NULL; }
-+ void EnableMainPerformance(CThread *thread) { CSingleLock lock(m_critSection); m_mainPerformance.thread = thread; }
-+ void DisableMainPerformance() { CSingleLock lock(m_critSection); m_mainPerformance.thread = NULL; }
-
- CDVDMessageQueue* m_pAudioQueue;
- CDVDMessageQueue* m_pVideoQueue;
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp 2012-05-14 14:15:12.142220628 +0200
-@@ -518,7 +518,7 @@
- m_decode.msg = NULL;
- m_decode.Release();
-
-- g_dvdPerformanceCounter.EnableAudioDecodePerformance(ThreadHandle());
-+ g_dvdPerformanceCounter.EnableAudioDecodePerformance(this);
-
- #ifdef _WIN32
- CoInitializeEx(NULL, COINIT_MULTITHREADED);
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayer.cpp 2012-05-14 14:15:12.145220688 +0200
-@@ -348,7 +348,7 @@
-
- // if playing a file close it first
- // this has to be changed so we won't have to close it.
-- if(ThreadHandle())
-+ if(IsRunning())
- CloseFile();
-
- m_bAbortRequest = false;
-@@ -366,7 +366,7 @@
- m_ready.Reset();
-
- #if defined(HAS_VIDEO_PLAYBACK)
-- g_renderManager.PreInit();
-+ g_renderManager.PreInit(&m_clock);
- #endif
-
- Create();
-@@ -440,9 +440,8 @@
-
- m_messenger.Init();
-
-- g_dvdPerformanceCounter.EnableMainPerformance(ThreadHandle());
--
- CUtil::ClearTempFonts();
-+ g_dvdPerformanceCounter.EnableMainPerformance(this);
- }
-
- bool CDVDPlayer::OpenInputStream()
-@@ -1585,7 +1584,7 @@
-
- }
- else if (m_CurrentVideo.id >= 0
-- && m_CurrentVideo.inited == true
-+ && (m_CurrentVideo.inited == true || GetPlaySpeed() < 0)
- && m_SpeedState.lastpts != m_dvdPlayerVideo.GetCurrentPts()
- && m_SpeedState.lasttime != GetTime())
- {
-@@ -2262,6 +2261,11 @@
- if (speed != DVD_PLAYSPEED_PAUSE && m_playSpeed != DVD_PLAYSPEED_PAUSE && speed != m_playSpeed)
- m_callback.OnPlayBackSpeedChanged(speed / DVD_PLAYSPEED_NORMAL);
-
-+ if (m_playSpeed < 0 && speed >= 0)
-+ {
-+ m_messenger.Put(new CDVDMsgPlayerSeek(GetTime(), true, true, true));
-+ }
-+
- // if playspeed is different then DVD_PLAYSPEED_NORMAL or DVD_PLAYSPEED_PAUSE
- // audioplayer, stops outputing audio to audiorendere, but still tries to
- // sleep an correct amount for each packet
-@@ -2278,6 +2282,7 @@
- // until our buffers are somewhat filled
- if(m_pDemuxer)
- m_pDemuxer->SetSpeed(speed);
-+
- }
- else if (pMsg->IsType(CDVDMsg::PLAYER_CHANNEL_SELECT_NUMBER) && m_messenger.GetPacketCount(CDVDMsg::PLAYER_CHANNEL_SELECT_NUMBER) == 0)
- {
-@@ -2897,7 +2902,7 @@
- m_dvdPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
-
- /* audio normally won't consume full cpu, so let it have prio */
-- m_dvdPlayerAudio.SetPriority(GetThreadPriority(*this)+1);
-+ m_dvdPlayerAudio.SetPriority(GetPriority()+1);
-
- return true;
- }
-@@ -2962,11 +2967,11 @@
- // the CoreAudio audio device handler thread. We do the same for
- // the DVDPlayerVideo thread so it can run to sleep without getting
- // swapped out by a busy OS.
-- m_dvdPlayerVideo.SetPrioritySched_RR();
-+ m_dvdPlayerVideo.SetPriority(GetSchedRRPriority());
- #else
- /* use same priority for video thread as demuxing thread, as */
- /* otherwise demuxer will starve if video consumes the full cpu */
-- m_dvdPlayerVideo.SetPriority(GetThreadPriority(*this));
-+ m_dvdPlayerVideo.SetPriority(GetPriority());
- #endif
- return true;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-05-14 14:11:52.795931658 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp 2012-05-14 14:38:53.481710398 +0200
-@@ -189,7 +189,7 @@
- return false;
- }
-
-- if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && g_VideoReferenceClock.ThreadHandle() == NULL)
-+ if(g_guiSettings.GetBool("videoplayer.usedisplayasclock") && !g_VideoReferenceClock.IsRunning())
- {
- g_VideoReferenceClock.Create();
- //we have to wait for the clock to start otherwise alsa can cause trouble
-@@ -247,6 +247,7 @@
- m_stalled = m_messageQueue.GetPacketCount(CDVDMsg::DEMUXER_PACKET) == 0;
- m_started = false;
- m_codecname = m_pVideoCodec->GetName();
-+ g_renderManager.EnableBuffering(false);
- }
-
- void CDVDPlayerVideo::CloseStream(bool bWaitForBuffers)
-@@ -291,7 +292,7 @@
- m_iCurrentPts = DVD_NOPTS_VALUE;
- m_FlipTimeStamp = m_pClock->GetAbsoluteClock();
-
-- g_dvdPerformanceCounter.EnableVideoDecodePerformance(ThreadHandle());
-+ g_dvdPerformanceCounter.EnableVideoDecodePerformance(this);
- }
-
- void CDVDPlayerVideo::Process()
-@@ -311,8 +312,10 @@
-
- int iDropped = 0; //frames dropped in a row
- bool bRequestDrop = false;
-+ int iDropDirective;
-
- m_videoStats.Start();
-+ m_droppingStats.Reset();
-
- while (!m_bStop)
- {
-@@ -416,6 +419,8 @@
- picture.iFlags &= ~DVP_FLAG_ALLOCATED;
- m_packets.clear();
- m_started = false;
-+ m_droppingStats.Reset();
-+ g_renderManager.EnableBuffering(false);
- }
- else if (pMsg->IsType(CDVDMsg::GENERAL_FLUSH)) // private message sent by (CDVDPlayerVideo::Flush())
- {
-@@ -428,6 +433,8 @@
- //we need to recalculate the framerate
- //TODO: this needs to be set on a streamchange instead
- ResetFrameRateCalc();
-+ m_droppingStats.Reset();
-+ g_renderManager.EnableBuffering(false);
-
- m_stalled = true;
- m_started = false;
-@@ -445,6 +452,10 @@
- m_speed = static_cast(pMsg)->m_value;
- if(m_speed == DVD_PLAYSPEED_PAUSE)
- m_iNrOfPicturesNotToSkip = 0;
-+ m_droppingStats.Reset();
-+// g_renderManager.EnableBuffering(m_speed == DVD_PLAYSPEED_NORMAL);
-+ if (m_pVideoCodec)
-+ m_pVideoCodec->SetSpeed(m_speed);
- }
- else if (pMsg->IsType(CDVDMsg::PLAYER_STARTED))
- {
-@@ -479,6 +490,29 @@
- m_iNrOfPicturesNotToSkip = 1;
- }
-
-+ bRequestDrop = false;
-+ iDropDirective = CalcDropRequirement(pts);
-+ if (iDropDirective & EOS_VERYLATE)
-+ {
-+ if (m_bAllowDrop)
-+ {
-+ m_pullupCorrection.Flush();
-+ bRequestDrop = true;
-+ }
-+ }
-+ int codecControl = 0;
-+ if (iDropDirective & EOS_BUFFER_LEVEL)
-+ {
-+ if (iDropDirective & EOS_BUFFER_LEVEL)
-+ codecControl |= DVP_FLAG_DRAIN;
-+ }
-+ m_pVideoCodec->SetCodecControl(codecControl);
-+ if (iDropDirective & EOS_DROPPED)
-+ {
-+ m_iDroppedFrames++;
-+ iDropped++;
-+ }
-+
- #ifdef PROFILE
- bRequestDrop = false;
- #else
-@@ -488,6 +522,7 @@
- bRequestDrop = false;
- m_iDroppedRequest = 0;
- m_iLateFrames = 0;
-+ m_droppingStats.m_requestOutputDrop = false;
- }
- #endif
-
-@@ -526,7 +561,7 @@
- if(m_pVideoCodec->GetConvergeCount() > 0)
- {
- m_packets.push_back(DVDMessageListItem(pMsg, 0));
-- if(m_packets.size() > m_pVideoCodec->GetConvergeCount()
-+ if(m_packets.size() > m_pVideoCodec->GetConvergeCount()
- || m_packets.size() * frametime > DVD_SEC_TO_TIME(10))
- m_packets.pop_front();
- }
-@@ -536,11 +571,13 @@
- // picture from a demux packet, this should be reasonable
- // for libavformat as a demuxer as it normally packetizes
- // pictures when they come from demuxer
-- if(bRequestDrop && !bPacketDrop && (iDecoderState & VC_BUFFER) && !(iDecoderState & VC_PICTURE))
-- {
-- m_iDroppedFrames++;
-- iDropped++;
-- }
-+// if(bRequestDrop && !bPacketDrop && (iDecoderState & VC_BUFFER) && !(iDecoderState & VC_PICTURE))
-+// {
-+// m_iDroppedFrames++;
-+// iDropped++;
-+// }
-+
-+ bRequestDrop = false;
-
- // loop while no error
- while (!m_bStop)
-@@ -563,6 +600,8 @@
-
- m_pVideoCodec->Reset();
- m_packets.clear();
-+ picture.iFlags &= ~DVP_FLAG_ALLOCATED;
-+ g_renderManager.DiscardBuffer();
- break;
- }
-
-@@ -672,11 +711,15 @@
- CDVDCodecUtils::FreePicture(pTempYUVPackedPicture);
- #endif
-
-+ if (!m_bFpsInvalid)
-+ frametime = (double)DVD_TIME_BASE/m_fFrameRate;
-+
- if(m_started == false)
- {
- m_codecname = m_pVideoCodec->GetName();
- m_started = true;
- m_messageParent.Put(new CDVDMsgInt(CDVDMsg::PLAYER_STARTED, DVDPLAYER_VIDEO));
-+ g_renderManager.EnableBuffering(true);
- }
-
- // guess next frame pts. iDuration is always valid
-@@ -1039,6 +1082,10 @@
- flags |= CONF_FLAGS_FORMAT_VDPAU;
- formatstr = "VDPAU";
- break;
-+ case DVDVideoPicture::FMT_VDPAU_420:
-+ flags |= CONF_FLAGS_FORMAT_VDPAU_420;
-+ formatstr = "VDPAU_420";
-+ break;
- case DVDVideoPicture::FMT_DXVA:
- flags |= CONF_FLAGS_FORMAT_DXVA;
- formatstr = "DXVA";
-@@ -1054,6 +1101,10 @@
- flags |= CONF_FLAGS_FORMAT_CVBREF;
- formatstr = "BGRA";
- break;
-+ case DVDVideoPicture::FMT_XVBA:
-+ flags |= CONF_FLAGS_FORMAT_XVBA;
-+ formatstr = "XVBA";
-+ break;
- }
-
- if(m_bAllowFullscreen)
-@@ -1162,50 +1213,63 @@
- m_FlipTimeStamp += max(0.0, iSleepTime);
- m_FlipTimeStamp += iFrameDuration;
-
-- if (iSleepTime <= 0 && m_speed)
-- m_iLateFrames++;
-- else
-- m_iLateFrames = 0;
-+// if (iSleepTime <= 0 && m_speed)
-+// m_iLateFrames++;
-+// else
-+// m_iLateFrames = 0;
-+//
-+// // ask decoder to drop frames next round, as we are very late
-+// if(m_iLateFrames > 10)
-+// {
-+// if (!(pPicture->iFlags & DVP_FLAG_NOSKIP))
-+// {
-+// //if we're calculating the framerate,
-+// //don't drop frames until we've calculated a stable framerate
-+// if (m_bAllowDrop || m_speed != DVD_PLAYSPEED_NORMAL)
-+// {
-+// result |= EOS_VERYLATE;
-+// m_pullupCorrection.Flush(); //dropped frames mess up the pattern, so just flush it
-+// }
-+//
-+// //if we requested 5 drops in a row and we're still late, drop on output
-+// //this keeps a/v sync if the decoder can't drop, or we're still calculating the framerate
-+// if (m_iDroppedRequest > 5)
-+// {
-+// m_iDroppedRequest--; //decrease so we only drop half the frames
-+// return result | EOS_DROPPED;
-+// }
-+// m_iDroppedRequest++;
-+// }
-+// }
-+// else
-+// {
-+// m_iDroppedRequest = 0;
-+// }
-+
-+ if ((m_droppingStats.m_requestOutputDrop && !(pPicture->iFlags & DVP_FLAG_NOSKIP))
-+ || (pPicture->iFlags & DVP_FLAG_DROPPED))
-+ {
-+ m_droppingStats.AddOutputDropGain(pts, 1/m_fFrameRate);
-+ m_droppingStats.m_requestOutputDrop = false;
-+ CLog::Log(LOGDEBUG,"%s - dropped in output", __FUNCTION__);
-+ return result | EOS_DROPPED;
-+ }
-
-- // ask decoder to drop frames next round, as we are very late
-- if(m_iLateFrames > 10)
-+ if( m_speed < 0 )
- {
-- if (!(pPicture->iFlags & DVP_FLAG_NOSKIP))
-+ double decoderPts = m_droppingStats.m_lastDecoderPts;
-+ double renderPts = m_droppingStats.m_lastRenderPts;
-+ if (pts > renderPts)
- {
-- //if we're calculating the framerate,
-- //don't drop frames until we've calculated a stable framerate
-- if (m_bAllowDrop || m_speed != DVD_PLAYSPEED_NORMAL)
-+ if (decoderPts >= renderPts)
- {
-- result |= EOS_VERYLATE;
-- m_pullupCorrection.Flush(); //dropped frames mess up the pattern, so just flush it
-+ Sleep(200);
- }
--
-- //if we requested 5 drops in a row and we're still late, drop on output
-- //this keeps a/v sync if the decoder can't drop, or we're still calculating the framerate
-- if (m_iDroppedRequest > 5)
-- {
-- m_iDroppedRequest--; //decrease so we only drop half the frames
-- return result | EOS_DROPPED;
-- }
-- m_iDroppedRequest++;
-- }
-- }
-- else
-- {
-- m_iDroppedRequest = 0;
-- }
--
-- if( m_speed < 0 )
-- {
-- if( iClockSleep < -DVD_MSEC_TO_TIME(200)
-- && !(pPicture->iFlags & DVP_FLAG_NOSKIP) )
- return result | EOS_DROPPED;
-+ }
- }
-
-- if( (pPicture->iFlags & DVP_FLAG_DROPPED) )
-- return result | EOS_DROPPED;
--
-- if( m_speed != DVD_PLAYSPEED_NORMAL && limited )
-+ if( m_speed != DVD_PLAYSPEED_NORMAL && m_speed >= 0 && limited )
- {
- // calculate frame dropping pattern to render at this speed
- // we do that by deciding if this or next frame is closest
-@@ -1241,6 +1305,16 @@
- mDisplayField = FS_BOT;
- }
-
-+ int buffer = g_renderManager.WaitForBuffer(m_bStop);
-+ while (buffer < 0 && !CThread::m_bStop &&
-+ CDVDClock::GetAbsoluteClock(false) < iCurrentClock + iSleepTime + DVD_MSEC_TO_TIME(500) )
-+ {
-+ Sleep(1);
-+ buffer = g_renderManager.WaitForBuffer(m_bStop);
-+ }
-+ if (buffer < 0)
-+ return EOS_DROPPED;
-+
- ProcessOverlays(pPicture, pts);
- AutoCrop(pPicture);
-
-@@ -1257,7 +1331,7 @@
- if (index < 0)
- return EOS_DROPPED;
-
-- g_renderManager.FlipPage(CThread::m_bStop, (iCurrentClock + iSleepTime) / DVD_TIME_BASE, -1, mDisplayField);
-+ g_renderManager.FlipPage(CThread::m_bStop, pts, -1, mDisplayField, m_speed);
-
- return result;
- #else
-@@ -1271,7 +1345,8 @@
- if ((pPicture->format == DVDVideoPicture::FMT_YUV420P) ||
- (pPicture->format == DVDVideoPicture::FMT_NV12) ||
- (pPicture->format == DVDVideoPicture::FMT_YUY2) ||
-- (pPicture->format == DVDVideoPicture::FMT_UYVY))
-+ (pPicture->format == DVDVideoPicture::FMT_UYVY) ||
-+ (pPicture->format == DVDVideoPicture::FMT_VDPAU_420))
- {
- RECT crop;
-
-@@ -1500,7 +1575,7 @@
- double frameduration = m_pullupCorrection.GetFrameDuration();
-
- if (frameduration == DVD_NOPTS_VALUE ||
-- (g_advancedSettings.m_videoFpsDetect == 1 && m_pullupCorrection.GetPatternLength() > 1))
-+ (g_advancedSettings.m_videoFpsDetect == 1 && (m_pullupCorrection.GetPatternLength() > 1 && !m_bFpsInvalid)))
- {
- //reset the stored framerates if no good framerate was detected
- m_fStableFrameRate = 0.0;
-@@ -1556,3 +1631,142 @@
- m_iFrameRateCount = 0;
- }
- }
-+
-+int CDVDPlayerVideo::CalcDropRequirement(double pts)
-+{
-+ int result = 0;
-+ double iSleepTime;
-+ double iDecoderPts, iRenderPts;
-+ double iInterval;
-+ int interlaced;
-+ double iGain;
-+ double iLateness;
-+ bool bNewFrame;
-+ int iSkippedDeint = 0;
-+ int iBufferLevel;
-+
-+ // get decoder stats
-+ if (!m_pVideoCodec->GetPts(iDecoderPts, iSkippedDeint, interlaced))
-+ iDecoderPts = pts;
-+
-+ // get render stats
-+ g_renderManager.GetStats(iSleepTime, iRenderPts, iBufferLevel);
-+
-+ if (iBufferLevel < 2)
-+ {
-+ result |= EOS_BUFFER_LEVEL;
-+ if (iBufferLevel < 1)
-+ CLog::Log(LOGDEBUG,"--------------------- hurry: %d", iBufferLevel);
-+ }
-+
-+ bNewFrame = iDecoderPts != m_droppingStats.m_lastDecoderPts;
-+
-+ if (interlaced)
-+ iInterval = 2/m_fFrameRate*(double)DVD_TIME_BASE;
-+ else
-+ iInterval = 1/m_fFrameRate*(double)DVD_TIME_BASE;
-+
-+ // add any gains regardless of being late
-+ if (m_droppingStats.m_lastDecoderPts > 0
-+ && bNewFrame
-+ && m_bAllowDrop
-+ && m_droppingStats.m_dropRequests > 0)
-+ {
-+ iGain = (iDecoderPts - m_droppingStats.m_lastDecoderPts - iInterval)/(double)DVD_TIME_BASE;
-+ if (iSkippedDeint)
-+ {
-+ CDroppingStats::CGain gain;
-+ gain.gain = 1/m_fFrameRate;
-+ gain.pts = iDecoderPts;
-+ m_droppingStats.m_gain.push_back(gain);
-+ m_droppingStats.m_totalGain += gain.gain;
-+ result |= EOS_DROPPED;
-+ m_droppingStats.m_dropRequests = 0;
-+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - dropped de-interlacing cycle, Sleeptime: %f, Bufferlevel: %d", iSleepTime, iBufferLevel);
-+ }
-+ else if (iGain > 1/m_fFrameRate)
-+ {
-+ CDroppingStats::CGain gain;
-+ gain.gain = iGain;
-+ gain.pts = iDecoderPts;
-+ m_droppingStats.m_gain.push_back(gain);
-+ m_droppingStats.m_totalGain += iGain;
-+ result |= EOS_DROPPED;
-+ m_droppingStats.m_dropRequests = 0;
-+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - dropped in decoder, Sleeptime: %f, Bufferlevel: %d, Gain: %f", iSleepTime, iBufferLevel, iGain);
-+ }
-+
-+ }
-+ m_droppingStats.m_lastDecoderPts = iDecoderPts;
-+
-+ // subtract gains
-+ while (!m_droppingStats.m_gain.empty() &&
-+ iRenderPts >= m_droppingStats.m_gain.front().pts)
-+ {
-+ m_droppingStats.m_totalGain -= m_droppingStats.m_gain.front().gain;
-+ m_droppingStats.m_gain.pop_front();
-+ }
-+
-+// if (iSleepTime < 0)
-+// {
-+// CLog::Log(LOGNOTICE,"----- sleep: %f, gain :%f",
-+// iSleepTime, m_droppingStats.m_totalGain);
-+// }
-+
-+ // calculate lateness
-+ iLateness = iSleepTime + m_droppingStats.m_totalGain;
-+ if (iLateness < 0 && m_speed)
-+ {
-+ if (bNewFrame)
-+ m_droppingStats.m_lateFrames++;
-+
-+ // if lateness is smaller than frametime, we observe this state
-+ // for 10 cycles
-+ if (m_droppingStats.m_lateFrames > 10 || iLateness < -2/m_fFrameRate)
-+ {
-+ // is frame allowed to skip
-+ if (m_iNrOfPicturesNotToSkip <= 0)
-+ {
-+ result |= EOS_VERYLATE;
-+
-+ // drop in output
-+ if (m_droppingStats.m_dropRequests > 7 && g_graphicsContext.IsFullScreenVideo())
-+ {
-+ m_droppingStats.m_dropRequests--; //decrease so we only drop half the frames
-+ m_droppingStats.m_requestOutputDrop = true;
-+ CLog::Log(LOGNOTICE,"-------- drop output");
-+ }
-+ else if (bNewFrame)
-+ m_droppingStats.m_dropRequests++;
-+ }
-+ }
-+ }
-+ else
-+ {
-+ m_droppingStats.m_dropRequests = 0;
-+ m_droppingStats.m_lateFrames = 0;
-+ m_droppingStats.m_requestOutputDrop = false;
-+ }
-+ m_droppingStats.m_lastRenderPts = iRenderPts;
-+ return result;
-+}
-+
-+void CDroppingStats::Reset()
-+{
-+ m_gain.clear();
-+ m_totalGain = 0;
-+ m_lastDecoderPts = 0;
-+ m_lastRenderPts = 0;
-+ m_lateFrames = 0;
-+ m_dropRequests = 0;
-+ m_requestOutputDrop = false;
-+}
-+
-+void CDroppingStats::AddOutputDropGain(double pts, double frametime)
-+{
-+ CDroppingStats::CGain gain;
-+ gain.gain = frametime;
-+ gain.pts = pts;
-+ m_gain.push_back(gain);
-+ m_totalGain += frametime;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.h xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.h
---- xbmc-pvr-11.0.1/xbmc/cores/dvdplayer/DVDPlayerVideo.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/dvdplayer/DVDPlayerVideo.h 2012-05-14 14:15:12.150220789 +0200
-@@ -38,6 +38,26 @@
-
- #define VIDEO_PICTURE_QUEUE_SIZE 1
-
-+class CDroppingStats
-+{
-+public:
-+ void Reset();
-+ void AddOutputDropGain(double pts, double frametime);
-+ struct CGain
-+ {
-+ double gain;
-+ double pts;
-+ };
-+ std::deque m_gain;
-+ double m_totalGain;
-+ double m_lastDecoderPts;
-+ double m_lastRenderPts;
-+ unsigned int m_lateFrames;
-+ unsigned int m_dropRequests;
-+ bool m_requestOutputDrop;
-+};
-+
-+
- class CDVDPlayerVideo : public CThread
- {
- public:
-@@ -111,6 +131,7 @@
- #define EOS_ABORT 1
- #define EOS_DROPPED 2
- #define EOS_VERYLATE 4
-+#define EOS_BUFFER_LEVEL 8
-
- void AutoCrop(DVDVideoPicture* pPicture);
- void AutoCrop(DVDVideoPicture *pPicture, RECT &crop);
-@@ -130,9 +151,11 @@
- int m_iLateFrames;
- int m_iDroppedFrames;
- int m_iDroppedRequest;
-+ double m_iLastSleepTime;
-
- void ResetFrameRateCalc();
- void CalcFrameRate();
-+ int CalcDropRequirement(double pts);
-
- double m_fFrameRate; //framerate of the video currently playing
- bool m_bCalcFrameRate; //if we should calculate the framerate from the timestamps
-@@ -193,5 +216,7 @@
- CPullupCorrection m_pullupCorrection;
-
- std::list m_packets;
-+
-+ CDroppingStats m_droppingStats;
- };
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/paplayer/PAPlayer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/paplayer/PAPlayer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/paplayer/PAPlayer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/paplayer/PAPlayer.cpp 2012-05-14 14:15:12.151220809 +0200
-@@ -52,7 +52,7 @@
- // Supporting all open audio codec standards.
- // First one being nullsoft's nsv audio decoder format
-
--PAPlayer::PAPlayer(IPlayerCallback& callback) : IPlayer(callback)
-+PAPlayer::PAPlayer(IPlayerCallback& callback) : CThread("PAPlayer"), IPlayer(callback)
- {
- m_bIsPlaying = false;
- m_bPaused = false;
-@@ -168,7 +168,7 @@
-
- *m_currentFile = file;
-
-- if (ThreadHandle() == NULL)
-+ if (!IsRunning())
- Create();
-
- m_startEvent.Set();
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp 2012-05-14 14:15:12.155220890 +0200
-@@ -61,6 +61,9 @@
- VA_MICRO_VERSION == 0 && VA_SDS_VERSION < 5)))
-
- #endif
-+#ifdef HAVE_LIBXVBA
-+#include "cores/dvdplayer/DVDCodecs/Video/XVBA.h"
-+#endif
-
- #ifdef HAS_GLX
- #include
-@@ -121,6 +124,9 @@
- #ifdef HAVE_LIBVDPAU
- vdpau = NULL;
- #endif
-+#ifdef HAVE_LIBXVBA
-+ xvba = NULL;
-+#endif
- }
-
- CLinuxRendererGL::YUVBUFFER::~YUVBUFFER()
-@@ -224,7 +230,7 @@
-
- void CLinuxRendererGL::ManageTextures()
- {
-- m_NumYV12Buffers = 2;
-+// m_NumYV12Buffers = NUM_BUFFERS;
- //m_iYV12RenderBuffer = 0;
- return;
- }
-@@ -241,6 +247,11 @@
- else
- CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
-
-+ // function pointer for texture might change in
-+ // call to LoadShaders
-+ for (int i = 0 ; i < m_NumYV12Buffers ; i++)
-+ (this->*m_textureDelete)(i);
-+
- // create the yuv textures
- LoadShaders();
-
-@@ -567,6 +578,18 @@
-
- glFinish();
- m_bValidated = false;
-+ m_iYV12RenderBuffer = 0;
-+}
-+
-+void CLinuxRendererGL::ReleaseBuffer(int idx)
-+{
-+ YUVBUFFER &buf = m_buffers[idx];
-+#ifdef HAVE_LIBVDPAU
-+ SAFE_RELEASE(buf.vdpau);
-+#endif
-+#ifdef HAVE_LIBXVBA
-+ SAFE_RELEASE(buf.xvba);
-+#endif
- }
-
- void CLinuxRendererGL::Update(bool bPauseDrawing)
-@@ -640,6 +663,18 @@
-
- glDisable(GL_POLYGON_STIPPLE);
- }
-+ else if( CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU_420
-+ && !(flags & (RENDER_FLAG_TOP | RENDER_FLAG_BOT)))
-+ {
-+ glDisable(GL_BLEND);
-+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-+ Render(flags | RENDER_FLAG_TOP, index);
-+
-+ glEnable(GL_BLEND);
-+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-+ glColor4f(1.0f, 1.0f, 1.0f, 128 / 255.0f);
-+ Render(flags | RENDER_FLAG_BOT , index);
-+ }
- else
- Render(flags, index);
-
-@@ -718,11 +753,6 @@
-
- m_buffers[m_iYV12RenderBuffer].flipindex = ++m_flipindex;
-
--#ifdef HAVE_LIBVDPAU
-- if((m_renderMethod & RENDER_VDPAU) && m_buffers[m_iYV12RenderBuffer].vdpau)
-- m_buffers[m_iYV12RenderBuffer].vdpau->Present();
--#endif
--
- return;
- }
-
-@@ -737,7 +767,6 @@
- m_resolution = RES_DESKTOP;
-
- m_iYV12RenderBuffer = 0;
-- m_NumYV12Buffers = 2;
-
- // setup the background colour
- m_clearColour = (float)(g_advancedSettings.m_videoBlackBarColour & 0xff) / 0xff;
-@@ -817,7 +846,7 @@
- case VS_SCALINGMETHOD_LINEAR:
- SetTextureFilter(m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR);
- m_renderQuality = RQ_SINGLEPASS;
-- if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI)) && m_nonLinStretch)
-+ if (((m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA)) && m_nonLinStretch)
- {
- m_pVideoFilterShader = new StretchFilterShader();
- if (!m_pVideoFilterShader->CompileAndLink())
-@@ -898,6 +927,11 @@
- CLog::Log(LOGNOTICE, "GL: Using VAAPI render method");
- m_renderMethod = RENDER_VAAPI;
- }
-+ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA)
-+ {
-+ CLog::Log(LOGNOTICE, "GL: Using XVBA render method");
-+ m_renderMethod = RENDER_XVBA;
-+ }
- else
- {
- int requestedMethod = g_guiSettings.GetInt("videoplayer.rendermethod");
-@@ -1026,12 +1060,24 @@
- m_textureCreate = &CLinuxRendererGL::CreateVDPAUTexture;
- m_textureDelete = &CLinuxRendererGL::DeleteVDPAUTexture;
- }
-+ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU_420)
-+ {
-+ m_textureUpload = &CLinuxRendererGL::UploadVDPAUTexture420;
-+ m_textureCreate = &CLinuxRendererGL::CreateVDPAUTexture420;
-+ m_textureDelete = &CLinuxRendererGL::DeleteVDPAUTexture420;
-+ }
- else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VAAPI)
- {
- m_textureUpload = &CLinuxRendererGL::UploadVAAPITexture;
- m_textureCreate = &CLinuxRendererGL::CreateVAAPITexture;
- m_textureDelete = &CLinuxRendererGL::DeleteVAAPITexture;
- }
-+ else if (CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_XVBA)
-+ {
-+ m_textureUpload = &CLinuxRendererGL::UploadXVBATexture;
-+ m_textureCreate = &CLinuxRendererGL::CreateXVBATexture;
-+ m_textureDelete = &CLinuxRendererGL::DeleteXVBATexture;
-+ }
- else
- {
- // setup default YV12 texture handlers
-@@ -1132,6 +1178,13 @@
- RenderVAAPI(renderBuffer, m_currentField);
- }
- #endif
-+#ifdef HAVE_LIBXVBA
-+ else if (m_renderMethod & RENDER_XVBA)
-+ {
-+ UpdateVideoFilter();
-+ RenderXVBA(renderBuffer, m_currentField);
-+ }
-+#endif
- else
- {
- RenderSoftware(renderBuffer, m_currentField);
-@@ -1434,17 +1487,12 @@
- void CLinuxRendererGL::RenderVDPAU(int index, int field)
- {
- #ifdef HAVE_LIBVDPAU
-- YUVPLANE &plane = m_buffers[index].fields[field][0];
-- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
--
-- if (!vdpau)
-- return;
-+ YUVPLANE &plane = m_buffers[index].fields[0][1];
-
- glEnable(m_textureTarget);
- glActiveTextureARB(GL_TEXTURE0);
-- glBindTexture(m_textureTarget, plane.id);
-
-- vdpau->BindPixmap();
-+ glBindTexture(m_textureTarget, plane.id);
-
- // Try some clamping or wrapping
- glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-@@ -1502,8 +1550,6 @@
- if (m_pVideoFilterShader)
- m_pVideoFilterShader->Disable();
-
-- vdpau->ReleasePixmap();
--
- glBindTexture (m_textureTarget, 0);
- glDisable(m_textureTarget);
- #endif
-@@ -1598,6 +1644,77 @@
- #endif
- }
-
-+void CLinuxRendererGL::RenderXVBA(int index, int field)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YUVPLANE &plane = m_buffers[index].fields[0][1];
-+
-+ glEnable(m_textureTarget);
-+ glActiveTextureARB(GL_TEXTURE0);
-+
-+ glBindTexture(m_textureTarget, plane.id);
-+
-+ // Try some clamping or wrapping
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-+
-+ if (m_pVideoFilterShader)
-+ {
-+ GLint filter;
-+ if (!m_pVideoFilterShader->GetTextureFilter(filter))
-+ filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR;
-+
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter);
-+ m_pVideoFilterShader->SetSourceTexture(0);
-+ m_pVideoFilterShader->SetWidth(m_sourceWidth);
-+ m_pVideoFilterShader->SetHeight(m_sourceHeight);
-+
-+ //disable non-linear stretch when a dvd menu is shown, parts of the menu are rendered through the overlay renderer
-+ //having non-linear stretch on breaks the alignment
-+ if (g_application.m_pPlayer && g_application.m_pPlayer->IsInMenu())
-+ m_pVideoFilterShader->SetNonLinStretch(1.0);
-+ else
-+ m_pVideoFilterShader->SetNonLinStretch(pow(g_settings.m_fPixelRatio, g_advancedSettings.m_videoNonLinStretchRatio));
-+
-+ m_pVideoFilterShader->Enable();
-+ }
-+ else
-+ {
-+ GLint filter = m_scalingMethod == VS_SCALINGMETHOD_NEAREST ? GL_NEAREST : GL_LINEAR;
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, filter);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, filter);
-+ }
-+
-+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-+ VerifyGLState();
-+
-+ glBegin(GL_QUADS);
-+ if (m_textureTarget==GL_TEXTURE_2D)
-+ {
-+ glTexCoord2f(plane.rect.x1, plane.rect.y1); glVertex2f(m_destRect.x1, m_destRect.y1);
-+ glTexCoord2f(plane.rect.x2, plane.rect.y1); glVertex2f(m_destRect.x2, m_destRect.y1);
-+ glTexCoord2f(plane.rect.x2, plane.rect.y2); glVertex2f(m_destRect.x2, m_destRect.y2);
-+ glTexCoord2f(plane.rect.x1, plane.rect.y2); glVertex2f(m_destRect.x1, m_destRect.y2);
-+ }
-+ else
-+ {
-+ glTexCoord2f(m_destRect.x1, m_destRect.y1); glVertex4f(m_destRect.x1, m_destRect.y1, 0.0f, 0.0f);
-+ glTexCoord2f(m_destRect.x2, m_destRect.y1); glVertex4f(m_destRect.x2, m_destRect.y1, 1.0f, 0.0f);
-+ glTexCoord2f(m_destRect.x2, m_destRect.y2); glVertex4f(m_destRect.x2, m_destRect.y2, 1.0f, 1.0f);
-+ glTexCoord2f(m_destRect.x1, m_destRect.y2); glVertex4f(m_destRect.x1, m_destRect.y2, 0.0f, 1.0f);
-+ }
-+ glEnd();
-+ VerifyGLState();
-+
-+ if (m_pVideoFilterShader)
-+ m_pVideoFilterShader->Disable();
-+
-+ glBindTexture (m_textureTarget, 0);
-+ glDisable(m_textureTarget);
-+#endif
-+}
-+
- void CLinuxRendererGL::RenderSoftware(int index, int field)
- {
- YUVPLANES &planes = m_buffers[index].fields[field];
-@@ -2162,12 +2279,14 @@
- {
- #ifdef HAVE_LIBVDPAU
- YUVPLANE &plane = m_buffers[index].fields[0][0];
-+ YUVFIELDS &fields = m_buffers[index].fields;
-
- SAFE_RELEASE(m_buffers[index].vdpau);
-
- if(plane.id && glIsTexture(plane.id))
- glDeleteTextures(1, &plane.id);
- plane.id = 0;
-+ fields[0][1].id = 0;
- #endif
- }
-
-@@ -2201,8 +2320,156 @@
- void CLinuxRendererGL::UploadVDPAUTexture(int index)
- {
- #ifdef HAVE_LIBVDPAU
-+ VDPAU::CVdpauRenderPicture *vdpau = m_buffers[index].vdpau;
-+
-+ unsigned int flipindex = m_buffers[index].flipindex;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+
-+ if (!vdpau)
-+ {
-+ fields[0][1].id = plane.id;
-+ m_eventTexturesDone[index]->Set();
-+ CLog::Log(LOGWARNING,"--------- no vdpau texture, index: %d", index);
-+ return;
-+ }
-+
-+// CLog::Log(LOGNOTICE,"-------- rendered output surf: %d", vdpau->sourceIdx);
-+// CLog::Log(LOGNOTICE,"-------- pts: %f", vdpau->DVDPic.pts);
-+ fields[0][1].id = vdpau->texture[0];
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+}
-+
-+void CLinuxRendererGL::DeleteVDPAUTexture420(int index)
-+{
-+#ifdef HAVE_LIBVDPAU
-+ YUVPLANE &plane = m_buffers[index].fields[0][0];
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+
-+ SAFE_RELEASE(m_buffers[index].vdpau);
-+
-+ if(plane.id && glIsTexture(plane.id))
-+ glDeleteTextures(1, &plane.id);
-+ plane.id = 0;
-+ fields[1][0].id = 0;
-+ fields[1][1].id = 0;
-+ fields[2][0].id = 0;
-+ fields[2][1].id = 0;
-+
-+#endif
-+}
-+
-+bool CLinuxRendererGL::CreateVDPAUTexture420(int index)
-+{
-+#ifdef HAVE_LIBVDPAU
-+ YV12Image &im = m_buffers[index].image;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+ GLuint *pbo = m_buffers[index].pbo;
-+
-+ DeleteVDPAUTexture420(index);
-+
-+ memset(&im , 0, sizeof(im));
-+ memset(&fields, 0, sizeof(fields));
-+
-+ im.cshift_x = 1;
-+ im.cshift_y = 1;
-+
-+ im.plane[0] = NULL;
-+ im.plane[1] = NULL;
-+ im.plane[2] = NULL;
-+
-+ for(int p = 0;p<3;p++)
-+ {
-+ pbo[p] = None;
-+ }
-+
-+ glEnable(m_textureTarget);
-+ glGenTextures(1, &plane.id);
-+ glDisable(m_textureTarget);
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+ return true;
-+}
-+
-+void CLinuxRendererGL::UploadVDPAUTexture420(int index)
-+{
-+#ifdef HAVE_LIBVDPAU
-+ VDPAU::CVdpauRenderPicture *vdpau = m_buffers[index].vdpau;
-+ YV12Image &im = m_buffers[index].image;
-+
-+ unsigned int flipindex = m_buffers[index].flipindex;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+
-+ if (!vdpau)
-+ {
-+ fields[1][0].id = plane.id;
-+ fields[1][1].id = plane.id;
-+ fields[2][0].id = plane.id;
-+ fields[2][1].id = plane.id;
-+ m_eventTexturesDone[index]->Set();
-+ return;
-+ }
-+
-+ im.height = vdpau->texHeight;
-+ im.width = vdpau->texWidth;
-+
-+ // YUV
-+ for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
-+ {
-+ int fieldshift = (f==FIELD_FULL) ? 0 : 1;
-+ YUVPLANES &planes = fields[f];
-+
-+ planes[0].texwidth = im.width;
-+ planes[0].texheight = im.height >> fieldshift;
-+
-+ planes[1].texwidth = planes[0].texwidth >> im.cshift_x;
-+ planes[1].texheight = planes[0].texheight >> im.cshift_y;
-+ planes[2].texwidth = planes[1].texwidth;
-+ planes[2].texheight = planes[1].texheight;
-+
-+ for (int p = 0; p < 3; p++)
-+ {
-+ planes[p].pixpertex_x = 1;
-+ planes[p].pixpertex_y = 1;
-+ }
-+ }
-+ // crop
-+// m_sourceRect.x1 += vdpau->crop.x1;
-+// m_sourceRect.x2 -= vdpau->crop.x2;
-+// m_sourceRect.y1 += vdpau->crop.y1;
-+// m_sourceRect.y2 -= vdpau->crop.y2;
-+
-+ // set textures
-+ fields[1][0].id = vdpau->texture[0];
-+ fields[1][1].id = vdpau->texture[2];
-+ fields[2][0].id = vdpau->texture[1];
-+ fields[2][1].id = vdpau->texture[3];
-+
-+ glEnable(m_textureTarget);
-+ for (int f = 1; f < 3; f++)
-+ {
-+ for (int p=0;p<2;p++)
-+ {
-+ glBindTexture(m_textureTarget,fields[f][p].id);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-+
-+ glBindTexture(m_textureTarget,0);
-+ VerifyGLState();
-+ }
-+ fields[f][2].id = fields[f][1].id;
-+ }
-+ CalculateTextureSourceRects(index, 3);
-+ glDisable(m_textureTarget);
-+
- m_eventTexturesDone[index]->Set();
-- glPixelStorei(GL_UNPACK_ALIGNMENT,1); //what's this for?
- #endif
- }
-
-@@ -2352,6 +2619,93 @@
- #endif
- }
-
-+void CLinuxRendererGL::DeleteXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YUVPLANE &plane = m_buffers[index].fields[0][0];
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+
-+ SAFE_RELEASE(m_buffers[index].xvba);
-+
-+ if(plane.id && glIsTexture(plane.id))
-+ glDeleteTextures(1, &plane.id);
-+ plane.id = 0;
-+ fields[0][1].id = 0;
-+#endif
-+}
-+
-+bool CLinuxRendererGL::CreateXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ YV12Image &im = m_buffers[index].image;
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][0];
-+
-+ DeleteXVBATexture(index);
-+
-+ memset(&im , 0, sizeof(im));
-+ memset(&fields, 0, sizeof(fields));
-+
-+ glGenTextures(1, &plane.id);
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+ return true;
-+}
-+
-+void CLinuxRendererGL::UploadXVBATexture(int index)
-+{
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CXvbaRenderPicture *xvba = m_buffers[index].xvba;
-+ YV12Image &im = m_buffers[index].image;
-+
-+ YUVFIELDS &fields = m_buffers[index].fields;
-+ YUVPLANE &plane = fields[0][1];
-+
-+ if (!xvba)
-+ {
-+ fields[0][1].id = fields[0][0].id;
-+ m_eventTexturesDone[index]->Set();
-+ CLog::Log(LOGWARNING,"CLinuxRendererGL::UploadXVBATexture no xvba texture, index: %d", index);
-+ return;
-+ }
-+// xvba->Transfer();
-+
-+ fields[0][1].id = xvba->texture;
-+
-+ im.height = xvba->texHeight;
-+ im.width = xvba->texWidth;
-+
-+ plane.texwidth = xvba->texWidth;
-+ plane.texheight = xvba->texHeight;
-+ plane.pixpertex_x = 1;
-+ plane.pixpertex_y = 1;
-+
-+ plane.rect = m_sourceRect;
-+ plane.width = im.width;
-+ plane.height = im.height;
-+
-+ plane.height /= plane.pixpertex_y;
-+ plane.rect.y1 /= plane.pixpertex_y;
-+ plane.rect.y2 /= plane.pixpertex_y;
-+ plane.width /= plane.pixpertex_x;
-+ plane.rect.x1 /= plane.pixpertex_x;
-+ plane.rect.x2 /= plane.pixpertex_x;
-+
-+ if (m_textureTarget == GL_TEXTURE_2D)
-+ {
-+ plane.height /= plane.texheight;
-+ plane.rect.y1 /= plane.texheight;
-+ plane.rect.y2 /= plane.texheight;
-+ plane.width /= plane.texwidth;
-+ plane.rect.x1 /= plane.texwidth;
-+ plane.rect.x2 /= plane.texwidth;
-+ }
-+
-+ m_eventTexturesDone[index]->Set();
-+#endif
-+}
-+
- void CLinuxRendererGL::UploadYUV422PackedTexture(int source)
- {
- YUVBUFFER& buf = m_buffers[source];
-@@ -2935,6 +3289,9 @@
- if (m_renderMethod & RENDER_VAAPI)
- return false;
-
-+ if (m_renderMethod & RENDER_XVBA)
-+ return false;
-+
- return (m_renderMethod & RENDER_GLSL)
- || (m_renderMethod & RENDER_ARB)
- || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE);
-@@ -2948,6 +3305,9 @@
- if (m_renderMethod & RENDER_VAAPI)
- return false;
-
-+ if (m_renderMethod & RENDER_XVBA)
-+ return false;
-+
- return (m_renderMethod & RENDER_GLSL)
- || (m_renderMethod & RENDER_ARB)
- || ((m_renderMethod & RENDER_SW) && glewIsSupported("GL_ARB_imaging") == GL_TRUE);
-@@ -2971,7 +3331,8 @@
- if (feature == RENDERFEATURE_NONLINSTRETCH)
- {
- if (((m_renderMethod & RENDER_GLSL) && !(m_renderMethod & RENDER_POT)) ||
-- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI))
-+ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) ||
-+ (m_renderMethod & RENDER_XVBA))
- return true;
- }
-
-@@ -2998,12 +3359,13 @@
- if(method == VS_INTERLACEMETHOD_AUTO)
- return true;
-
-- if(m_renderMethod & RENDER_VDPAU)
-+ if(m_renderMethod & RENDER_VDPAU ||
-+ CONF_FLAGS_FORMAT_MASK(m_iFlags) == CONF_FLAGS_FORMAT_VDPAU_420)
- {
- #ifdef HAVE_LIBVDPAU
-- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
-- if(vdpau)
-- return vdpau->Supports(method);
-+ VDPAU::CVdpauRenderPicture *vdpauPic = m_buffers[m_iYV12RenderBuffer].vdpau;
-+ if(vdpauPic && vdpauPic->vdpau)
-+ return vdpauPic->vdpau->Supports(method);
- #endif
- return false;
- }
-@@ -3027,6 +3389,16 @@
- return false;
- }
-
-+ if(m_renderMethod & RENDER_XVBA)
-+ {
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CXvbaRenderPicture *xvba = m_buffers[m_iYV12RenderBuffer].xvba;
-+ if(xvba)
-+ return xvba->xvba->Supports(method);
-+#endif
-+ return false;
-+ }
-+
- #ifdef TARGET_DARWIN
- // YADIF too slow for HD but we have no methods to fall back
- // to something that works so just turn it off.
-@@ -3069,7 +3441,7 @@
- || method == VS_SCALINGMETHOD_LANCZOS3)
- {
- if ((glewIsSupported("GL_EXT_framebuffer_object") && (m_renderMethod & RENDER_GLSL)) ||
-- (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI))
-+ (m_renderMethod & RENDER_VDPAU) || (m_renderMethod & RENDER_VAAPI) || (m_renderMethod & RENDER_XVBA))
- {
- // spline36 and lanczos3 are only allowed through advancedsettings.xml
- if(method != VS_SCALINGMETHOD_SPLINE36
-@@ -3088,9 +3460,9 @@
- if(m_renderMethod & RENDER_VDPAU)
- {
- #ifdef HAVE_LIBVDPAU
-- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
-- if(vdpau)
-- return vdpau->AutoInterlaceMethod();
-+ VDPAU::CVdpauRenderPicture *vdpauPic = m_buffers[m_iYV12RenderBuffer].vdpau;
-+ if(vdpauPic && vdpauPic->vdpau)
-+ return vdpauPic->vdpau->AutoInterlaceMethod();
- #endif
- return VS_INTERLACEMETHOD_NONE;
- }
-@@ -3136,20 +3508,31 @@
- }
-
- #ifdef HAVE_LIBVDPAU
--void CLinuxRendererGL::AddProcessor(CVDPAU* vdpau)
-+void CLinuxRendererGL::AddProcessor(VDPAU::CVdpauRenderPicture *vdpau, int index)
- {
-- YUVBUFFER &buf = m_buffers[NextYV12Texture()];
-+ YUVBUFFER &buf = m_buffers[index];
-+ VDPAU::CVdpauRenderPicture *pic = vdpau->Acquire();
- SAFE_RELEASE(buf.vdpau);
-- buf.vdpau = (CVDPAU*)vdpau->Acquire();
-+ buf.vdpau = pic;
- }
- #endif
-
- #ifdef HAVE_LIBVA
--void CLinuxRendererGL::AddProcessor(VAAPI::CHolder& holder)
-+void CLinuxRendererGL::AddProcessor(VAAPI::CHolder& holder, int index)
- {
-- YUVBUFFER &buf = m_buffers[NextYV12Texture()];
-+ YUVBUFFER &buf = m_buffers[index];
- buf.vaapi.surface = holder.surface;
- }
- #endif
-
-+#ifdef HAVE_LIBXVBA
-+void CLinuxRendererGL::AddProcessor(XVBA::CXvbaRenderPicture* xvba, int index)
-+{
-+ YUVBUFFER &buf = m_buffers[index];
-+ XVBA::CXvbaRenderPicture *pic = xvba->Acquire();
-+ SAFE_RELEASE(buf.xvba);
-+ buf.xvba = pic;
-+}
-+#endif
-+
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/LinuxRendererGL.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/LinuxRendererGL.h 2012-05-14 14:15:12.156220910 +0200
-@@ -35,13 +35,14 @@
-
- class CRenderCapture;
-
--class CVDPAU;
- class CBaseTexture;
- namespace Shaders { class BaseYUV2RGBShader; }
- namespace Shaders { class BaseVideoFilterShader; }
- namespace VAAPI { struct CHolder; }
-+namespace VDPAU { class CVdpauRenderPicture; }
-+namespace XVBA { class CXvbaRenderPicture; }
-
--#define NUM_BUFFERS 3
-+#define NUM_BUFFERS 10
-
-
- #undef ALIGN
-@@ -94,6 +95,7 @@
- RENDER_VDPAU=0x08,
- RENDER_POT=0x10,
- RENDER_VAAPI=0x20,
-+ RENDER_XVBA=0x40,
- };
-
- enum RenderQuality
-@@ -141,14 +143,19 @@
- virtual void UnInit();
- virtual void Reset(); /* resets renderer after seek for example */
- virtual void Flush();
-+ virtual void ReleaseBuffer(int idx);
-+ virtual void SetProcessorSize(int numBuffers) { m_NumYV12Buffers = numBuffers; }
-+ virtual unsigned int GetProcessorSize() { return m_NumYV12Buffers; }
-
- #ifdef HAVE_LIBVDPAU
-- virtual void AddProcessor(CVDPAU* vdpau);
-+ virtual void AddProcessor(VDPAU::CVdpauRenderPicture* vdpau, int index);
- #endif
- #ifdef HAVE_LIBVA
-- virtual void AddProcessor(VAAPI::CHolder& holder);
-+ virtual void AddProcessor(VAAPI::CHolder& holder, int index);
-+#endif
-+#ifdef HAVE_LIBXVBA
-+ virtual void AddProcessor(XVBA::CXvbaRenderPicture* xvba, int index);
- #endif
--
- virtual void RenderUpdate(bool clear, DWORD flags = 0, DWORD alpha = 255);
-
- // Feature support
-@@ -190,6 +197,10 @@
- void DeleteVDPAUTexture(int index);
- bool CreateVDPAUTexture(int index);
-
-+ void UploadVDPAUTexture420(int index);
-+ void DeleteVDPAUTexture420(int index);
-+ bool CreateVDPAUTexture420(int index);
-+
- void UploadVAAPITexture(int index);
- void DeleteVAAPITexture(int index);
- bool CreateVAAPITexture(int index);
-@@ -198,6 +209,10 @@
- void DeleteYUV422PackedTexture(int index);
- bool CreateYUV422PackedTexture(int index);
-
-+ void UploadXVBATexture(int index);
-+ void DeleteXVBATexture(int index);
-+ bool CreateXVBATexture(int index);
-+
- void UploadRGBTexture(int index);
- void ToRGBFrame(YV12Image* im, unsigned flipIndexPlane, unsigned flipIndexBuf);
- void ToRGBFields(YV12Image* im, unsigned flipIndexPlaneTop, unsigned flipIndexPlaneBot, unsigned flipIndexBuf);
-@@ -210,7 +225,9 @@
- void RenderSinglePass(int renderBuffer, int field); // single pass glsl renderer
- void RenderSoftware(int renderBuffer, int field); // single pass s/w yuv2rgb renderer
- void RenderVDPAU(int renderBuffer, int field); // render using vdpau hardware
-+ void RenderVDPAUYV12(int renderBuffer, int field); // render using vdpau hardware
- void RenderVAAPI(int renderBuffer, int field); // render using vdpau hardware
-+ void RenderXVBA(int renderBuffer, int field); // render using xvba hardware
-
- CFrameBufferObject m_fbo;
-
-@@ -265,11 +282,14 @@
- GLuint pbo[MAX_PLANES];
-
- #ifdef HAVE_LIBVDPAU
-- CVDPAU* vdpau;
-+ VDPAU::CVdpauRenderPicture *vdpau;
- #endif
- #ifdef HAVE_LIBVA
- VAAPI::CHolder& vaapi;
- #endif
-+#ifdef HAVE_LIBXVBA
-+ XVBA::CXvbaRenderPicture *xvba;
-+#endif
- };
-
- typedef YUVBUFFER YUVBUFFERS[NUM_BUFFERS];
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.cpp 2012-05-14 14:15:12.157220930 +0200
-@@ -89,7 +89,7 @@
- CRenderer::CRenderer()
- {
- m_render = 0;
-- m_decode = (m_render + 1) % 2;
-+// m_decode = (m_render + 1) % 2;
- }
-
- CRenderer::~CRenderer()
-@@ -154,9 +154,10 @@
- {
- CSingleLock lock(m_section);
-
-- for(int i = 0; i < 2; i++)
-+ for(int i = 0; i < m_iNumBuffers; i++)
- Release(m_buffers[i]);
-
-+ m_render = 0;
- Release(m_cleanup);
- }
-
-@@ -164,10 +165,23 @@
- {
- CSingleLock lock(m_section);
-
-- m_render = m_decode;
-- m_decode =(m_decode + 1) % 2;
-+// m_render = m_decode;
-+ m_render = (m_render + 1) % m_iNumBuffers;
-+
-+// Release(m_buffers[m_decode]);
-+}
-+
-+void CRenderer::SetBuffer(int idx)
-+{
-+ CSingleLock lock(m_section);
-+ Release(m_buffers[idx]);
-+ m_decode = idx;
-+}
-
-- Release(m_buffers[m_decode]);
-+void CRenderer::ReleaseBuffer(int idx)
-+{
-+ CSingleLock lock(m_section);
-+ Release(m_buffers[idx]);
- }
-
- void CRenderer::Render()
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/OverlayRenderer.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/OverlayRenderer.h 2012-05-14 14:15:12.157220930 +0200
-@@ -99,6 +99,9 @@
- void Flip();
- void Render();
- void Flush();
-+ void SetNumBuffers(int numBuffers) { m_iNumBuffers = numBuffers; }
-+ void SetBuffer(int idx);
-+ void ReleaseBuffer(int idx);
-
- protected:
-
-@@ -124,7 +127,8 @@
- void Release(SElementV& list);
-
- CCriticalSection m_section;
-- SElementV m_buffers[2];
-+ SElementV m_buffers[10];
-+ int m_iNumBuffers;
- int m_decode;
- int m_render;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderFlags.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderFlags.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderFlags.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderFlags.h 2012-05-14 14:15:12.158220950 +0200
-@@ -76,8 +76,10 @@
- #define CONF_FLAGS_FORMAT_YUY2 0x008000
- #define CONF_FLAGS_FORMAT_DXVA 0x010000
- #define CONF_FLAGS_FORMAT_VDPAU 0x020000
-+#define CONF_FLAGS_FORMAT_VDPAU_420 0x22000
- #define CONF_FLAGS_FORMAT_VAAPI 0x030000
- #define CONF_FLAGS_FORMAT_OMXEGL 0x040000
- #define CONF_FLAGS_FORMAT_CVBREF 0x080000
- #define CONF_FLAGS_FORMAT_BYPASS 0x100000
-+#define CONF_FLAGS_FORMAT_XVBA 0x200000
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.cpp 2012-05-14 14:15:12.160220990 +0200
-@@ -26,6 +26,7 @@
- #include "utils/MathUtils.h"
- #include "threads/SingleLock.h"
- #include "utils/log.h"
-+#include "utils/TimeUtils.h"
-
- #include "Application.h"
- #include "settings/Settings.h"
-@@ -53,6 +54,8 @@
- #include "../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h"
- #include "../dvdplayer/DVDCodecs/DVDCodecUtils.h"
-
-+#include "windowing/WindowingFactory.h"
-+
- #define MAXPRESENTDELAY 0.500
-
- /* at any point we want an exclusive lock on rendermanager */
-@@ -246,6 +249,7 @@
- m_bReconfigured = true;
- m_presentstep = PRESENT_IDLE;
- m_presentevent.Set();
-+// ResetRenderBuffer();
- }
-
- return result;
-@@ -277,8 +281,12 @@
- if (!m_pRenderer)
- return;
-
-+ if (m_presentstep == PRESENT_IDLE)
-+ PrepareNextRender();
-+
- if(m_presentstep == PRESENT_FLIP)
- {
-+ FlipRenderBuffer();
- m_overlays.Flip();
- m_pRenderer->FlipPage(m_presentsource);
- m_presentstep = PRESENT_FRAME;
-@@ -286,6 +294,8 @@
- }
- }
-
-+// CLog::Log(LOGNOTICE,"------ current: %d", m_iCurrentRenderBuffer);
-+
- if (g_advancedSettings.m_videoDisableBackgroundDeinterlace)
- {
- CSharedLock lock(m_sharedSection);
-@@ -297,7 +307,7 @@
- m_presentevent.Set();
- }
-
--unsigned int CXBMCRenderManager::PreInit()
-+unsigned int CXBMCRenderManager::PreInit(CDVDClock *pClock)
- {
- CRetakeLock lock(m_sharedSection);
-
-@@ -305,6 +315,7 @@
- m_presenterr = 0.0;
- m_errorindex = 0;
- memset(m_errorbuff, 0, sizeof(m_errorbuff));
-+ m_pClock = pClock;
-
- m_bIsStarted = false;
- m_bPauseDrawing = false;
-@@ -323,6 +334,17 @@
-
- UpdateDisplayLatency();
-
-+ m_swapCount = 1;
-+// std::string Vendor = g_Windowing.GetRenderVendor();
-+// std::transform(Vendor.begin(), Vendor.end(), Vendor.begin(), ::tolower);
-+// if (Vendor.compare(0, 3, "ati") == 0)
-+// {
-+// m_swapCount = 2;
-+// }
-+ ResetRenderBuffer();
-+ m_bUseBuffering = false;
-+ m_overlays.SetNumBuffers(m_iNumRenderBuffers);
-+ m_pRenderer->SetProcessorSize(m_iNumRenderBuffers);
- return m_pRenderer->PreInit();
- }
-
-@@ -351,7 +373,9 @@
-
- CRetakeLock lock(m_sharedSection);
- m_pRenderer->Flush();
-+ m_overlays.Flush();
- m_flushEvent.Set();
-+ ResetRenderBuffer();
- }
- else
- {
-@@ -512,25 +536,21 @@
- m_captures.erase(it);
- }
-
--void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/)
-+void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0LL*/, int source /*= -1*/, EFIELDSYNC sync /*= FS_NONE*/, int speed /*= 0*/)
- {
-- if(timestamp - GetPresentTime() > MAXPRESENTDELAY)
-- timestamp = GetPresentTime() + MAXPRESENTDELAY;
--
-- /* can't flip, untill timestamp */
-- if(!g_graphicsContext.IsFullScreenVideo())
-- WaitPresentTime(timestamp);
--
-- /* make sure any queued frame was fully presented */
-- double timeout = m_presenttime + 1.0;
-- while(m_presentstep != PRESENT_IDLE && !bStop)
-+ if (!m_bUseBuffering)
- {
-- if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ /* make sure any queued frame was fully presented */
-+ double timeout = m_presenttime + 1.0;
-+ while(m_presentstep != PRESENT_IDLE && !bStop)
- {
-- CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for previous frame");
-- return;
-+ if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ {
-+ CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for previous frame");
-+ return;
-+ }
- }
-- };
-+ }
-
- if(bStop)
- return;
-@@ -538,58 +558,67 @@
- { CRetakeLock lock(m_sharedSection);
- if(!m_pRenderer) return;
-
-- m_presenttime = timestamp;
-- m_presentfield = sync;
-- m_presentstep = PRESENT_FLIP;
-- m_presentsource = source;
-+ double presenttime = timestamp;
-+ EFIELDSYNC presentfield = sync;
-+ EPRESENTMETHOD presentmethod;
-+
- EDEINTERLACEMODE deinterlacemode = g_settings.m_currentVideoSettings.m_DeinterlaceMode;
- EINTERLACEMETHOD interlacemethod = AutoInterlaceMethodInternal(g_settings.m_currentVideoSettings.m_InterlaceMethod);
-
- bool invert = false;
-
- if (deinterlacemode == VS_DEINTERLACEMODE_OFF)
-- m_presentmethod = PRESENT_METHOD_SINGLE;
-+ presentmethod = PRESENT_METHOD_SINGLE;
- else
- {
-- if (deinterlacemode == VS_DEINTERLACEMODE_AUTO && m_presentfield == FS_NONE)
-- m_presentmethod = PRESENT_METHOD_SINGLE;
-+ if (deinterlacemode == VS_DEINTERLACEMODE_AUTO && presentfield == FS_NONE)
-+ presentmethod = PRESENT_METHOD_SINGLE;
- else
- {
-- if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BLEND) m_presentmethod = PRESENT_METHOD_BLEND;
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE) m_presentmethod = PRESENT_METHOD_WEAVE;
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED) { m_presentmethod = PRESENT_METHOD_WEAVE ; invert = true; }
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB) m_presentmethod = PRESENT_METHOD_BOB;
-- else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED) { m_presentmethod = PRESENT_METHOD_BOB; invert = true; }
-- else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BOB) m_presentmethod = PRESENT_METHOD_BOB;
-- else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BEST) m_presentmethod = PRESENT_METHOD_BOB;
-- else m_presentmethod = PRESENT_METHOD_SINGLE;
-+ if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BLEND) presentmethod = PRESENT_METHOD_BLEND;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE) presentmethod = PRESENT_METHOD_WEAVE;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_WEAVE_INVERTED) { presentmethod = PRESENT_METHOD_WEAVE ; invert = true; }
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB) presentmethod = PRESENT_METHOD_BOB;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_RENDER_BOB_INVERTED) { presentmethod = PRESENT_METHOD_BOB; invert = true; }
-+ else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BOB) presentmethod = PRESENT_METHOD_BOB;
-+ else if (interlacemethod == VS_INTERLACEMETHOD_DXVA_BEST) presentmethod = PRESENT_METHOD_BOB;
-+ else presentmethod = PRESENT_METHOD_SINGLE;
-
- /* default to odd field if we want to deinterlace and don't know better */
-- if (deinterlacemode == VS_DEINTERLACEMODE_FORCE && m_presentfield == FS_NONE)
-- m_presentfield = FS_TOP;
-+ if (deinterlacemode == VS_DEINTERLACEMODE_FORCE && presentfield == FS_NONE)
-+ presentfield = FS_TOP;
-
- /* invert present field */
- if(invert)
- {
-- if( m_presentfield == FS_BOT )
-- m_presentfield = FS_TOP;
-+ if( presentfield == FS_BOT )
-+ presentfield = FS_TOP;
- else
-- m_presentfield = FS_BOT;
-+ presentfield = FS_BOT;
- }
- }
- }
-
-+ FlipFreeBuffer();
-+ m_renderBuffers[m_iOutputRenderBuffer].pts = timestamp;
-+ m_renderBuffers[m_iOutputRenderBuffer].presentfield = presentfield;
-+ m_renderBuffers[m_iOutputRenderBuffer].presentmethod = presentmethod;
-+ m_speed = speed;
- }
-
- g_application.NewFrame();
-- /* wait untill render thread have flipped buffers */
-- timeout = m_presenttime + 1.0;
-- while(m_presentstep == PRESENT_FLIP && !bStop)
-+
-+ if (!m_bUseBuffering)
- {
-- if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ /* wait untill render thread have flipped buffers */
-+ double timeout = m_presenttime + 1.0;
-+ while(m_presentstep == PRESENT_FLIP && !bStop)
- {
-- CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for flip to complete");
-- return;
-+ if(!m_presentevent.WaitMSec(100) && GetPresentTime() > timeout && !bStop)
-+ {
-+ CLog::Log(LOGWARNING, "CRenderManager::FlipPage - timeout waiting for flip to complete");
-+ return;
-+ }
- }
- }
- }
-@@ -631,8 +660,12 @@
- if (!m_pRenderer)
- return;
-
-+ if (m_presentstep == PRESENT_IDLE)
-+ PrepareNextRender();
-+
- if(m_presentstep == PRESENT_FLIP)
- {
-+ FlipRenderBuffer();
- m_overlays.Flip();
- m_pRenderer->FlipPage(m_presentsource);
- m_presentstep = PRESENT_FRAME;
-@@ -647,6 +680,8 @@
- WaitPresentTime(m_presenttime);
-
- m_presentevent.Set();
-+
-+ m_rendertime = CurrentHostCounter();
- }
-
- /* simple present method */
-@@ -753,7 +788,7 @@
- return 1;
-
- YV12Image image;
-- int index = m_pRenderer->GetImage(&image);
-+ int index = m_pRenderer->GetImage(&image, (m_iOutputRenderBuffer + 1) % m_iNumRenderBuffers);
-
- if(index < 0)
- return index;
-@@ -776,8 +811,9 @@
- CDVDCodecUtils::CopyDXVA2Picture(&image, &pic);
- }
- #ifdef HAVE_LIBVDPAU
-- else if(pic.format == DVDVideoPicture::FMT_VDPAU)
-- m_pRenderer->AddProcessor(pic.vdpau);
-+ else if(pic.format == DVDVideoPicture::FMT_VDPAU
-+ || pic.format == DVDVideoPicture::FMT_VDPAU_420)
-+ m_pRenderer->AddProcessor(pic.vdpau, index);
- #endif
- #ifdef HAVE_LIBOPENMAX
- else if(pic.format == DVDVideoPicture::FMT_OMXEGL)
-@@ -789,7 +825,11 @@
- #endif
- #ifdef HAVE_LIBVA
- else if(pic.format == DVDVideoPicture::FMT_VAAPI)
-- m_pRenderer->AddProcessor(*pic.vaapi);
-+ m_pRenderer->AddProcessor(*pic.vaapi, index);
-+#endif
-+#ifdef HAVE_LIBXVBA
-+ else if(pic.format == DVDVideoPicture::FMT_XVBA)
-+ m_pRenderer->AddProcessor(pic.xvba, index);
- #endif
- m_pRenderer->ReleaseImage(index, false);
-
-@@ -809,3 +849,212 @@
-
- return mInt;
- }
-+
-+int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop)
-+{
-+ CSharedLock lock(m_sharedSection);
-+ if (!m_pRenderer)
-+ return -1;
-+
-+ //wait up to a second as this is our slowest allowed output rate
-+ double timeout = GetPresentTime() + 0.1;
-+ while(!HasFreeBuffer() && !bStop)
-+ {
-+ lock.Leave();
-+ m_flipEvent.WaitMSec(50);
-+ if(GetPresentTime() > timeout && !bStop)
-+ {
-+ CLog::Log(LOGWARNING, "CRenderManager::WaitForBuffer - timeout waiting for buffer");
-+ return -1;
-+ }
-+ lock.Enter();
-+ }
-+ lock.Leave();
-+
-+ { CRetakeLock lock(m_sharedSection);
-+ m_overlays.SetBuffer((m_iOutputRenderBuffer + 1) % m_iNumRenderBuffers);
-+ }
-+
-+ if (bStop)
-+ return -1;
-+
-+ return 1;
-+}
-+
-+int CXBMCRenderManager::GetNextRenderBufferIndex()
-+{
-+ if (m_iOutputRenderBuffer == m_iCurrentRenderBuffer)
-+ return -1;
-+ return (m_iCurrentRenderBuffer + 1) % m_iNumRenderBuffers;
-+}
-+
-+void CXBMCRenderManager::FlipRenderBuffer()
-+{
-+ m_iCurrentRenderBuffer = GetNextRenderBufferIndex();
-+// CLog::Log(LOGNOTICE,"-------- flip render: %d", m_iCurrentRenderBuffer);
-+}
-+
-+int CXBMCRenderManager::FlipFreeBuffer()
-+{
-+ // See "Render Buffer State Description" in header for information.
-+ if (HasFreeBuffer())
-+ {
-+ m_bAllRenderBuffersDisplayed = false;
-+ m_iOutputRenderBuffer = (m_iOutputRenderBuffer + 1) % m_iNumRenderBuffers;
-+ return m_iOutputRenderBuffer;
-+ }
-+}
-+
-+bool CXBMCRenderManager::HasFreeBuffer()
-+{
-+ if (!m_bUseBuffering)
-+ {
-+ if (m_iOutputRenderBuffer != m_iCurrentRenderBuffer)
-+ return false;
-+ else
-+ return true;
-+ }
-+
-+ int outputPlusSwap = (m_iOutputRenderBuffer + m_swapCount) % m_iNumRenderBuffers;
-+ if ((m_iOutputRenderBuffer == m_iDisplayedRenderBuffer && !m_bAllRenderBuffersDisplayed)
-+ || outputPlusSwap == m_iCurrentRenderBuffer)
-+ return false;
-+ else
-+ return true;
-+}
-+
-+void CXBMCRenderManager::ResetRenderBuffer()
-+{
-+ m_iNumRenderBuffers = 5;
-+ m_iCurrentRenderBuffer = 0;
-+ m_iFlipRequestRenderBuffer = 0;
-+ m_iOutputRenderBuffer = 0;
-+ m_iDisplayedRenderBuffer = 0;
-+ m_bAllRenderBuffersDisplayed = true;
-+ m_sleeptime = 1.0;
-+ m_presentPts = DVD_NOPTS_VALUE;
-+// m_bUseBuffering = true;
-+ m_speed = 0;
-+}
-+
-+void CXBMCRenderManager::PrepareNextRender()
-+{
-+ int idx = GetNextRenderBufferIndex();
-+ if (idx < 0)
-+ {
-+ if (m_speed >= DVD_PLAYSPEED_NORMAL && g_graphicsContext.IsFullScreenVideo())
-+ CLog::Log(LOGNOTICE,"----------- no buffer, out: %d, current: %d, display: %d",
-+ m_iOutputRenderBuffer, m_iCurrentRenderBuffer, m_iDisplayedRenderBuffer);
-+ return;
-+ }
-+
-+ double iClockSleep, iPlayingClock, iCurrentClock;
-+ iPlayingClock = m_pClock->GetClock(iCurrentClock, false);
-+ iClockSleep = m_renderBuffers[idx].pts - iPlayingClock;
-+
-+ if (m_speed)
-+ iClockSleep = iClockSleep * DVD_PLAYSPEED_NORMAL / m_speed;
-+
-+ double presenttime = (iCurrentClock + iClockSleep) / DVD_TIME_BASE;
-+ double clocktime = iCurrentClock / DVD_TIME_BASE;
-+ if(presenttime - clocktime > MAXPRESENTDELAY)
-+ presenttime = clocktime + MAXPRESENTDELAY;
-+
-+ m_sleeptime = presenttime - clocktime;
-+
-+// double interval;
-+// if (g_VideoReferenceClock.GetRefreshRate(&interval) > 0)
-+// {
-+// if (m_swaptime > interval * 0.7)
-+// {
-+// presenttime += interval;
-+// CLog::Log(LOGDEBUG,"------------ very long swaptime");
-+// }
-+// }
-+
-+ if (g_graphicsContext.IsFullScreenVideo() || presenttime <= clocktime+0.01)
-+ {
-+ m_presentPts = m_renderBuffers[idx].pts;
-+ m_presenttime = presenttime;
-+ m_presentmethod = m_renderBuffers[idx].presentmethod;
-+ m_presentfield = m_renderBuffers[idx].presentfield;
-+ m_presentstep = PRESENT_FLIP;
-+ m_presentsource = idx;
-+ }
-+}
-+
-+void CXBMCRenderManager::EnableBuffering(bool enable)
-+{
-+ CRetakeLock lock(m_sharedSection);
-+ m_bUseBuffering = enable;
-+ if (!m_bUseBuffering)
-+ m_iOutputRenderBuffer = m_iCurrentRenderBuffer;
-+
-+ CLog::Log(LOGDEBUG, "CXBMCRenderManager::EnableBuffering - %d", m_bUseBuffering);
-+}
-+
-+void CXBMCRenderManager::DiscardBuffer()
-+{
-+ CRetakeLock lock(m_sharedSection);
-+ m_iOutputRenderBuffer = m_iCurrentRenderBuffer;
-+}
-+
-+void CXBMCRenderManager::NotifyDisplayFlip()
-+{
-+ CRetakeLock lock(m_sharedSection);
-+ if (!m_pRenderer)
-+ return;
-+
-+// if (g_graphicsContext.IsFullScreenVideo())
-+// {
-+// uint64_t diff = CurrentHostCounter() - m_rendertime;
-+// m_swaptime = ((double)(diff))/CurrentHostFrequency();
-+// int waittime = (int)((diff*1000LL)/CurrentHostFrequency());
-+// if (waittime > 15)
-+// {
-+// CLog::Log(LOGNOTICE,"------------------ wait swap buffers: %f, sleep: %f", m_swaptime, m_sleeptime);
-+// }
-+// }
-+
-+ int last = m_iDisplayedRenderBuffer;
-+ m_iDisplayedRenderBuffer = (m_iCurrentRenderBuffer + m_iNumRenderBuffers - m_swapCount) % m_iNumRenderBuffers;
-+ m_iFlipRequestRenderBuffer = m_iCurrentRenderBuffer;
-+
-+// // we have caught up with output so all buffers are re-usable
-+// if (last != m_iDisplayedRenderBuffer
-+// && m_iDisplayedRenderBuffer == m_iOutputRenderBuffer)
-+// {
-+// CLog::Log(LOGNOTICE,"-------------- all displayed");
-+// m_bAllRenderBuffersDisplayed = true;
-+// }
-+
-+ if (last != m_iDisplayedRenderBuffer
-+ && m_iDisplayedRenderBuffer != m_iCurrentRenderBuffer)
-+ {
-+ m_pRenderer->ReleaseBuffer(m_iDisplayedRenderBuffer);
-+ m_overlays.ReleaseBuffer(m_iDisplayedRenderBuffer);
-+ }
-+
-+ lock.Leave();
-+ m_flipEvent.Set();
-+}
-+
-+bool CXBMCRenderManager::GetStats(double &sleeptime, double &pts, int &bufferLevel)
-+{
-+ CSharedLock lock(m_sharedSection);
-+ sleeptime = m_sleeptime;
-+ pts = m_presentPts;
-+ bufferLevel = (m_iOutputRenderBuffer - m_iCurrentRenderBuffer + m_iNumRenderBuffers) % m_iNumRenderBuffers;
-+ return true;
-+}
-+
-+bool CXBMCRenderManager::HasFrame()
-+{
-+ CSharedLock lock(m_sharedSection);
-+ if (m_presentstep == PRESENT_IDLE &&
-+ GetNextRenderBufferIndex() < 0 &&
-+ m_speed > 0)
-+ return false;
-+ else
-+ return true;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.h xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.h
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/RenderManager.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/RenderManager.h 2012-05-14 14:15:12.161221010 +0200
-@@ -39,10 +39,11 @@
- #include "OverlayRenderer.h"
-
- class CRenderCapture;
-+class CDVDClock;
-
- namespace DXVA { class CProcessor; }
- namespace VAAPI { class CSurfaceHolder; }
--class CVDPAU;
-+namespace VDPAU { struct CVdpauRenderPicture; }
- struct DVDVideoPicture;
-
- #define ERRORBUFFSIZE 30
-@@ -73,8 +74,8 @@
-
- int AddVideoPicture(DVDVideoPicture& picture);
-
-- void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE);
-- unsigned int PreInit();
-+ void FlipPage(volatile bool& bStop, double timestamp = 0.0, int source = -1, EFIELDSYNC sync = FS_NONE, int speed = 0);
-+ unsigned int PreInit(CDVDClock *pClock);
- void UnInit();
- bool Flush();
-
-@@ -182,6 +183,13 @@
-
- CSharedSection& GetSection() { return m_sharedSection; };
-
-+ int WaitForBuffer(volatile bool& bStop);
-+ void NotifyDisplayFlip();
-+ bool GetStats(double &sleeptime, double &pts, int &bufferLevel);
-+ bool HasFrame();
-+ void EnableBuffering(bool enable);
-+ void DiscardBuffer();
-+
- protected:
- void Render(bool clear, DWORD flags, DWORD alpha);
-
-@@ -190,6 +198,13 @@
- void PresentBob(bool clear, DWORD flags, DWORD alpha);
- void PresentBlend(bool clear, DWORD flags, DWORD alpha);
-
-+ int GetNextRenderBufferIndex();
-+ void FlipRenderBuffer();
-+ int FlipFreeBuffer();
-+ bool HasFreeBuffer();
-+ void ResetRenderBuffer();
-+ void PrepareNextRender();
-+
- EINTERLACEMETHOD AutoInterlaceMethodInternal(EINTERLACEMETHOD mInt);
-
- bool m_bPauseDrawing; // true if we should pause rendering
-@@ -220,6 +235,43 @@
- double m_displayLatency;
- void UpdateDisplayLatency();
-
-+ // Render Buffer State Description:
-+ //
-+ // Output: is the buffer about to or having its texture prepared for render (ie from output thread).
-+ // Cannot go past the "Displayed" buffer (otherwise we will probably overwrite buffers not yet
-+ // displayed or even rendered).
-+ // Current: is the current buffer being or having been submitted for render to back buffer.
-+ // Cannot go past "Output" buffer (else it would be rendering old output).
-+ // FlipRequest: is the render buffer that has last been submitted for render AND importantly has had
-+ // swap-buffer flip subsequently invoked (thus flip to front buffer is requested for vblank
-+ // subsequent to render completion).
-+ // Displayed: is the buffer that is now considered to be safely copied from back buffer to front buffer
-+ // (we assume that after two swap-buffer flips for the same "Current" render buffer that that
-+ // buffer will be safe, but otherwise we consider that only the previous-to-"Current" is guaranteed).
-+ // Last: is the last buffer successfully submitted for render to back buffer (purpose: to rollback to in
-+ // unexpected case where a texture render fails).
-+
-+ int m_iCurrentRenderBuffer;
-+ int m_iNumRenderBuffers;
-+// int m_iLastRenderBuffer;
-+ int m_iFlipRequestRenderBuffer;
-+ int m_iOutputRenderBuffer;
-+ int m_iDisplayedRenderBuffer;
-+ bool m_bAllRenderBuffersDisplayed;
-+ bool m_bUseBuffering;
-+ int m_speed;
-+ CEvent m_flipEvent;
-+
-+ struct
-+ {
-+ double pts;
-+ EFIELDSYNC presentfield;
-+ EPRESENTMETHOD presentmethod;
-+ }m_renderBuffers[5];
-+
-+ double m_sleeptime;
-+ double m_presentPts;
-+
- double m_presenttime;
- double m_presentcorr;
- double m_presenterr;
-@@ -231,7 +283,10 @@
- int m_presentsource;
- CEvent m_presentevent;
- CEvent m_flushEvent;
--
-+ CDVDClock *m_pClock;
-+ uint64_t m_rendertime;
-+ double m_swaptime;
-+ unsigned int m_swapCount;
-
- OVERLAY::CRenderer m_overlays;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
---- xbmc-pvr-11.0.1/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp 2012-05-14 14:15:12.162221031 +0200
-@@ -186,6 +186,8 @@
- m_defines += "#define XBMC_YUY2\n";
- else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_UYVY)
- m_defines += "#define XBMC_UYVY\n";
-+ else if (CONF_FLAGS_FORMAT_MASK(flags) == CONF_FLAGS_FORMAT_VDPAU_420)
-+ m_defines += "#define XBMC_VDPAU_NV12\n";
-
- VertexShader()->LoadSource("yuv2rgb_vertex.glsl", m_defines);
- #elif HAS_GLES == 2
-diff -Naur xbmc-pvr-11.0.1/xbmc/dialogs/GUIDialogCache.cpp xbmc-pvr-11.0.1.patch/xbmc/dialogs/GUIDialogCache.cpp
---- xbmc-pvr-11.0.1/xbmc/dialogs/GUIDialogCache.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/dialogs/GUIDialogCache.cpp 2012-05-14 14:15:12.163221052 +0200
-@@ -29,7 +29,7 @@
- #include "threads/SingleLock.h"
- #include "utils/TimeUtils.h"
-
--CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const CStdString& strHeader, const CStdString& strMsg)
-+CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const CStdString& strHeader, const CStdString& strMsg) : CThread("CGUIDialogCache")
- {
- m_pDlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/FileCache.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileCache.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/FileCache.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileCache.cpp 2012-05-14 14:15:12.163221052 +0200
-@@ -79,7 +79,7 @@
- };
-
-
--CFileCache::CFileCache()
-+CFileCache::CFileCache() : CThread("CFileCache")
- {
- m_bDeleteCache = true;
- m_nSeekResult = 0;
-@@ -95,7 +95,7 @@
- m_cacheFull = false;
- }
-
--CFileCache::CFileCache(CCacheStrategy *pCache, bool bDeleteCache)
-+CFileCache::CFileCache(CCacheStrategy *pCache, bool bDeleteCache) : CThread("CFileCache")
- {
- m_pCache = pCache;
- m_bDeleteCache = bDeleteCache;
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/FilePipe.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/FilePipe.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/FilePipe.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/FilePipe.cpp 2012-05-14 14:15:12.164221072 +0200
-@@ -24,6 +24,8 @@
- #include "PipesManager.h"
- #include "utils/StringUtils.h"
-
-+#define INFINITE 0xFFFFFFFF
-+
- using namespace XFILE;
-
- CFilePipe::CFilePipe() : m_pos(0), m_length(-1), m_pipe(NULL)
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/FileRar.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileRar.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/FileRar.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/FileRar.cpp 2012-05-14 14:15:12.165221092 +0200
-@@ -43,7 +43,7 @@
- #define SEEKTIMOUT 30000
-
- #ifdef HAS_FILESYSTEM_RAR
--CFileRarExtractThread::CFileRarExtractThread() : hRunning(true), hQuit(true)
-+CFileRarExtractThread::CFileRarExtractThread() : CThread("CFileRarExtractThread"), hRunning(true), hQuit(true)
- {
- m_pArc = NULL;
- m_pCmd = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/HTSPDirectory.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/HTSPDirectory.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/HTSPDirectory.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/HTSPDirectory.cpp 2012-05-14 14:15:12.166221112 +0200
-@@ -76,7 +76,7 @@
- static CCriticalSection g_section;
-
-
--CHTSPDirectorySession::CHTSPDirectorySession()
-+CHTSPDirectorySession::CHTSPDirectorySession() : CThread("CHTSPDirectorySession")
- {
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/LastFMDirectory.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/LastFMDirectory.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/LastFMDirectory.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/LastFMDirectory.cpp 2012-05-14 14:15:12.167221132 +0200
-@@ -69,7 +69,7 @@
- m_dlgProgress->Progress();
- }
-
-- CThread thread(this);
-+ CThread thread(this, "CLastFMDirectory");
- m_strSource = url;
- m_strDestination = "special://temp/lastfm.xml";
- thread.Create();
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/MythSession.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/MythSession.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/MythSession.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/MythSession.cpp 2012-05-14 14:15:12.168221152 +0200
-@@ -359,7 +359,7 @@
- return;
- }
-
--CMythSession::CMythSession(const CURL& url)
-+CMythSession::CMythSession(const CURL& url) : CThread("CMythSession")
- {
- m_control = NULL;
- m_event = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/PipesManager.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/PipesManager.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/PipesManager.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/PipesManager.cpp 2012-05-14 14:15:12.169221172 +0200
-@@ -23,6 +23,8 @@
- #include "threads/SingleLock.h"
- #include "Application.h"
-
-+#define INFINITE 0xFFFFFFFF
-+
- #ifndef min
- #define min(a,b) ((a) < (b) ? (a) : (b))
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/RarManager.h xbmc-pvr-11.0.1.patch/xbmc/filesystem/RarManager.h
---- xbmc-pvr-11.0.1/xbmc/filesystem/RarManager.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/RarManager.h 2012-05-14 14:15:12.169221172 +0200
-@@ -71,7 +71,7 @@
- CRarManager();
- ~CRarManager();
- bool CacheRarredFile(CStdString& strPathInCache, const CStdString& strRarPath,
-- const CStdString& strPathInRar, BYTE bOptions = EXFILE_AUTODELETE,
-+ const CStdString& strPathInRar, uint8_t bOptions = EXFILE_AUTODELETE,
- const CStdString& strDir =RAR_DEFAULT_CACHE, const int64_t iSize=-1);
- bool GetPathInCache(CStdString& strPathInCache, const CStdString& strRarPath,
- const CStdString& strPathInRar = "");
-diff -Naur xbmc-pvr-11.0.1/xbmc/filesystem/SAPDirectory.cpp xbmc-pvr-11.0.1.patch/xbmc/filesystem/SAPDirectory.cpp
---- xbmc-pvr-11.0.1/xbmc/filesystem/SAPDirectory.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/filesystem/SAPDirectory.cpp 2012-05-14 14:15:12.170221192 +0200
-@@ -272,7 +272,7 @@
- using namespace SDP;
-
-
--CSAPSessions::CSAPSessions()
-+CSAPSessions::CSAPSessions() : CThread("CSAPSessions")
- {
- m_socket = INVALID_SOCKET;
- }
-@@ -486,7 +486,7 @@
-
- CSingleLock lock(g_sapsessions.m_section);
-
-- if(g_sapsessions.ThreadHandle() == NULL)
-+ if(!g_sapsessions.IsRunning())
- g_sapsessions.Create();
-
- // check if we can find this session in our cache
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.cpp 2012-05-14 14:15:12.171221212 +0200
-@@ -181,9 +181,9 @@
- m_threadState = state;
- }
-
--void CGUIPythonWindow::WaitForActionEvent(unsigned int timeout)
-+void CGUIPythonWindow::WaitForActionEvent()
- {
-- g_pythonParser.WaitForEvent(m_actionEvent, timeout);
-+ g_pythonParser.WaitForEvent(m_actionEvent);
- m_actionEvent.Reset();
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindow.h 2012-05-14 14:15:12.171221212 +0200
-@@ -51,7 +51,7 @@
- virtual bool OnAction(const CAction &action);
- virtual bool OnBack(int actionID);
- void SetCallbackWindow(void* state, void *object);
-- void WaitForActionEvent(unsigned int timeout);
-+ void WaitForActionEvent();
- void PulseActionEvent();
- void SetDestroyAfterDeinit(bool destroy = true);
- protected:
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.cpp 2012-05-14 14:15:12.172221232 +0200
-@@ -279,9 +279,9 @@
- UpdateButtons();
- }
-
--void CGUIPythonWindowXML::WaitForActionEvent(unsigned int timeout)
-+void CGUIPythonWindowXML::WaitForActionEvent()
- {
-- g_pythonParser.WaitForEvent(m_actionEvent, timeout);
-+ g_pythonParser.WaitForEvent(m_actionEvent);
- m_actionEvent.Reset();
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/GUIPythonWindowXML.h 2012-05-14 14:15:12.173221252 +0200
-@@ -40,7 +40,7 @@
- virtual void AllocResources(bool forceLoad = false);
- virtual void FreeResources(bool forceUnLoad = false);
- void Process(unsigned int currentTime, CDirtyRegionList ®ions);
-- void WaitForActionEvent(unsigned int timeout);
-+ void WaitForActionEvent();
- void PulseActionEvent();
- void AddItem(CFileItemPtr fileItem,int itemPosition);
- void RemoveItem(int itemPosition);
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/window.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/window.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/xbmcmodule/window.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/xbmcmodule/window.cpp 2012-05-14 14:15:12.174221272 +0200
-@@ -540,11 +540,11 @@
-
- CPyThreadState pyState;
- if (WindowXML_Check(self))
-- ((CGUIPythonWindowXML*)self->pWindow)->WaitForActionEvent(INFINITE);
-+ ((CGUIPythonWindowXML*)self->pWindow)->WaitForActionEvent();
- else if (WindowXMLDialog_Check(self))
-- ((CGUIPythonWindowXMLDialog*)self->pWindow)->WaitForActionEvent(INFINITE);
-+ ((CGUIPythonWindowXMLDialog*)self->pWindow)->WaitForActionEvent();
- else
-- ((CGUIPythonWindow*)self->pWindow)->WaitForActionEvent(INFINITE);
-+ ((CGUIPythonWindow*)self->pWindow)->WaitForActionEvent();
- }
- }
- Py_INCREF(Py_None);
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/XBPython.cpp xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.cpp
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/XBPython.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.cpp 2012-05-14 14:15:12.175221293 +0200
-@@ -676,11 +676,11 @@
- m_globalEvent.Set();
- }
-
--void XBPython::WaitForEvent(CEvent& hEvent, unsigned int timeout)
-+void XBPython::WaitForEvent(CEvent& hEvent)
- {
- // wait for either this event our our global event
- XbmcThreads::CEventGroup eventGroup(&hEvent, &m_globalEvent, NULL);
-- eventGroup.wait(timeout);
-+ eventGroup.wait();
- m_globalEvent.Reset();
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/interfaces/python/XBPython.h xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.h
---- xbmc-pvr-11.0.1/xbmc/interfaces/python/XBPython.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/interfaces/python/XBPython.h 2012-05-14 14:15:12.176221314 +0200
-@@ -61,7 +61,7 @@
- void Process();
-
- void PulseGlobalEvent();
-- void WaitForEvent(CEvent& hEvent, unsigned int timeout);
-+ void WaitForEvent(CEvent& hEvent);
-
- int ScriptsSize();
- int GetPythonScriptId(int scriptPosition);
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/Makefile.in xbmc-pvr-11.0.1.patch/xbmc/linux/Makefile.in
---- xbmc-pvr-11.0.1/xbmc/linux/Makefile.in 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/Makefile.in 2012-05-14 14:15:12.176221314 +0200
-@@ -10,14 +10,11 @@
- LinuxResourceCounter.cpp \
- LinuxTimezone.cpp \
- PosixMountProvider.cpp \
-- XEventUtils.cpp \
- XFileUtils.cpp \
- XHandle.cpp \
- XLCDproc.cpp \
- XMemUtils.cpp \
-- XSyncUtils.cpp \
- XTimeUtils.cpp \
-- XThreadUtils.cpp \
-
- LIB=linux.a
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/PlatformDefs.h xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformDefs.h
---- xbmc-pvr-11.0.1/xbmc/linux/PlatformDefs.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformDefs.h 2012-05-14 14:15:12.177221334 +0200
-@@ -182,8 +182,6 @@
- #define EXCEPTION_EXECUTE_HANDLER ...
- //NOTE: dont try to define __except because it breaks g++ (already uses it).
-
--typedef pthread_t ThreadIdentifier;
--
- struct CXHandle; // forward declaration
- typedef CXHandle* HANDLE;
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/PlatformInclude.h xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformInclude.h
---- xbmc-pvr-11.0.1/xbmc/linux/PlatformInclude.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/PlatformInclude.h 2012-05-14 14:15:12.178221354 +0200
-@@ -25,10 +25,7 @@
- #include "PlatformDefs.h"
- #include "XHandlePublic.h"
- #include "XFileUtils.h"
--#include "XSyncUtils.h"
--#include "XEventUtils.h"
- #include "XTimeUtils.h"
--#include "XThreadUtils.h"
- #include "XMemUtils.h"
- #include "ConvUtils.h"
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XEventUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XEventUtils.cpp 1970-01-01 01:00:00.000000000 +0100
-@@ -1,144 +0,0 @@
--/*
-- * Copyright (C) 2005-2008 Team XBMC
-- * http://www.xbmc.org
-- *
-- * This Program 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, or (at your option)
-- * any later version.
-- *
-- * This Program 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 XBMC; see the file COPYING. If not, write to
-- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#include "system.h"
--#include "PlatformDefs.h"
--#include "XEventUtils.h"
--#include "XHandle.h"
--#include "utils/log.h"
--#include "threads/SingleLock.h"
--
--using namespace std;
--
--HANDLE WINAPI CreateEvent(void *pDummySec, bool bManualReset, bool bInitialState, char *szDummyName)
--{
-- CXHandle *pHandle = new CXHandle(CXHandle::HND_EVENT);
-- pHandle->m_bManualEvent = bManualReset;
-- pHandle->m_hCond = new XbmcThreads::ConditionVariable();
-- pHandle->m_hMutex = new CCriticalSection();
-- pHandle->m_bEventSet = false;
--
-- if (bInitialState)
-- SetEvent(pHandle);
--
-- return pHandle;
--}
--
--//
--// The state of a manual-reset event object remains signaled until it is set explicitly to the nonsignaled
--// state by the ResetEvent function. Any number of waiting threads, or threads that subsequently begin wait
--// operations for the specified event object by calling one of the wait functions, can be released while the
--// object's state is signaled.
--//
--// The state of an auto-reset event object remains signaled until a single waiting thread is released, at
--// which time the system automatically sets the state to nonsignaled. If no threads are waiting, the event
--// object's state remains signaled.
--//
--bool WINAPI SetEvent(HANDLE hEvent)
--{
-- if (hEvent == NULL || hEvent->m_hCond == NULL || hEvent->m_hMutex == NULL)
-- return false;
--
-- CSingleLock lock(*(hEvent->m_hMutex));
-- hEvent->m_bEventSet = true;
--
-- // we must guarantee that these handle's won't be deleted, until we are done
-- list events = hEvent->m_hParents;
-- for(list::iterator it = events.begin();it != events.end();it++)
-- DuplicateHandle(GetCurrentProcess(), *it, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
--
-- lock.Leave();
--
-- for(list::iterator it = events.begin();it != events.end();it++)
-- {
-- SetEvent(*it);
-- CloseHandle(*it);
-- }
--
-- DuplicateHandle(GetCurrentProcess(), hEvent, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
--
-- if (hEvent->m_bManualEvent == true)
-- hEvent->m_hCond->notifyAll();
-- else
-- hEvent->m_hCond->notify();
--
-- CloseHandle(hEvent);
--
-- return true;
--}
--
--bool WINAPI ResetEvent(HANDLE hEvent)
--{
-- if (hEvent == NULL || hEvent->m_hCond == NULL || hEvent->m_hMutex == NULL)
-- return false;
--
-- CSingleLock lock(*(hEvent->m_hMutex));
-- hEvent->m_bEventSet = false;
--
-- return true;
--}
--
--bool WINAPI PulseEvent(HANDLE hEvent)
--{
-- if (hEvent == NULL || hEvent->m_hCond == NULL || hEvent->m_hMutex == NULL)
-- return false;
--
-- CSingleLock lock(*(hEvent->m_hMutex));
-- // we must guarantee that these handle's won't be deleted, until we are done
-- list events = hEvent->m_hParents;
-- for(list::iterator it = events.begin();it != events.end();it++)
-- DuplicateHandle(GetCurrentProcess(), *it, GetCurrentProcess(), NULL, 0, FALSE, DUPLICATE_SAME_ACCESS);
--
-- if(events.size())
-- {
-- CLog::Log(LOGWARNING,"PulseEvent - ineffecient multiwait detected");
-- hEvent->m_bEventSet = true;
-- }
--
-- lock.Leave();
--
-- for(list::iterator it = events.begin();it != events.end();it++)
-- {
-- SetEvent(*it);
-- CloseHandle(*it);
--
-- if (hEvent->m_bManualEvent == false)
-- break;
-- }
--
-- // for multiwaits, we must yield some time to get the multiwaits to notice it was signaled
-- if(events.size())
-- Sleep(10);
--
-- // we should always unset the event on pulse
-- {
-- CSingleLock lock2(*(hEvent->m_hMutex));
-- hEvent->m_bEventSet = false;
-- }
--
-- if (hEvent->m_bManualEvent == true)
-- hEvent->m_hCond->notifyAll();
-- else
-- hEvent->m_hCond->notify();
--
-- return true;
--}
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.h xbmc-pvr-11.0.1.patch/xbmc/linux/XEventUtils.h
---- xbmc-pvr-11.0.1/xbmc/linux/XEventUtils.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XEventUtils.h 1970-01-01 01:00:00.000000000 +0100
-@@ -1,38 +0,0 @@
--#ifndef __X_EVENT_UTIL_H__
--#define __X_EVENT_UTIL_H__
--
--/*
-- * Copyright (C) 2005-2008 Team XBMC
-- * http://www.xbmc.org
-- *
-- * This Program 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, or (at your option)
-- * any later version.
-- *
-- * This Program 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 XBMC; see the file COPYING. If not, write to
-- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#include "XHandlePublic.h"
--
--#ifdef _LINUX
--
--HANDLE WINAPI CreateEvent(void *pDummySec, bool bManualReset, bool bInitialState, char *szDummyName);
--bool WINAPI SetEvent(HANDLE hEvent);
--bool WINAPI ResetEvent(HANDLE hEvent);
--bool WINAPI PulseEvent(HANDLE hEvent);
--
--#endif
--
--
--#endif
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XHandle.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XHandle.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.cpp 2012-05-14 14:15:12.185221494 +0200
-@@ -20,12 +20,15 @@
- */
-
- #include "XHandle.h"
--#include "XThreadUtils.h"
- #include "utils/log.h"
- #include "threads/SingleLock.h"
-
- int CXHandle::m_objectTracker[10] = {0};
-
-+HANDLE WINAPI GetCurrentProcess(void) {
-+ return (HANDLE)-1; // -1 a special value - pseudo handle
-+}
-+
- CXHandle::CXHandle()
- {
- Init();
-@@ -47,11 +50,6 @@
-
- Init();
-
-- if (m_threadValid)
-- {
-- CLog::Log(LOGERROR, "%s - thread handle copied instead of passed!", __FUNCTION__);
-- }
--
- if (src.m_hMutex)
- m_hMutex = new CCriticalSection();
-
-@@ -80,7 +78,7 @@
- CLog::Log(LOGERROR,"%s, destroying handle with ref count %d", __FUNCTION__, m_nRefCount);
- assert(false);
- }
--
-+
- if (m_hMutex) {
- delete m_hMutex;
- }
-@@ -93,10 +91,6 @@
- delete m_hCond;
- }
-
-- if (m_threadValid) {
-- pthread_join(m_hThread, NULL);
-- }
--
- if ( fd != 0 ) {
- close(fd);
- }
-@@ -107,11 +101,9 @@
- {
- fd=0;
- m_hMutex=NULL;
-- m_threadValid=false;
- m_hCond=NULL;
- m_type = HND_NULL;
- RecursionCount=0;
-- OwningThread=0;
- m_bManualEvent=FALSE;
- m_bEventSet=FALSE;
- m_nFindFileIterator=0 ;
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XHandle.h xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.h
---- xbmc-pvr-11.0.1/xbmc/linux/XHandle.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XHandle.h 2012-05-14 14:15:12.186221514 +0200
-@@ -25,7 +25,6 @@
- #ifndef _WIN32
-
- #include
--#include
-
- #include "PlatformDefs.h"
- #include "XHandlePublic.h"
-@@ -36,7 +35,7 @@
- struct CXHandle {
-
- public:
-- typedef enum { HND_NULL = 0, HND_FILE, HND_EVENT, HND_MUTEX, HND_THREAD, HND_FIND_FILE } HandleType;
-+ typedef enum { HND_NULL = 0, HND_FILE, HND_EVENT, HND_MUTEX, HND_FIND_FILE } HandleType;
-
- CXHandle();
- CXHandle(HandleType nType);
-@@ -47,8 +46,6 @@
- inline HandleType GetType() { return m_type; }
- void ChangeType(HandleType newType);
-
-- ThreadIdentifier m_hThread;
-- bool m_threadValid;
- XbmcThreads::ConditionVariable *m_hCond;
- std::list m_hParents;
-
-@@ -62,7 +59,6 @@
- // simulate mutex and critical section
- CCriticalSection *m_hMutex;
- int RecursionCount; // for mutex - for compatibility with WIN32 critical section
-- pthread_t OwningThread;
- int fd;
- bool m_bManualEvent;
- time_t m_tmCreation;
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.cpp 2012-05-14 14:15:12.187221534 +0200
-@@ -25,6 +25,10 @@
-
- #include "XMemUtils.h"
-
-+#ifdef __APPLE__
-+#include
-+#endif
-+
- #undef ALIGN
- #define ALIGN(value, alignment) (((value)+(alignment-1))&~(alignment-1))
-
-@@ -49,4 +53,130 @@
- free(pFull);
- }
-
-+#ifndef _WIN32
-+
-+#if defined(_LINUX) && !defined(__APPLE__) && !defined(__FreeBSD__)
-+static FILE* procMeminfoFP = NULL;
-+#endif
-+
-+void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
-+{
-+ if (!lpBuffer)
-+ return;
-+
-+ memset(lpBuffer, 0, sizeof(MEMORYSTATUSEX));
-+
-+#ifdef __APPLE__
-+ uint64_t physmem;
-+ size_t len = sizeof physmem;
-+ int mib[2] = { CTL_HW, HW_MEMSIZE };
-+ size_t miblen = sizeof(mib) / sizeof(mib[0]);
-+
-+ // Total physical memory.
-+ if (sysctl(mib, miblen, &physmem, &len, NULL, 0) == 0 && len == sizeof (physmem))
-+ lpBuffer->ullTotalPhys = physmem;
-+
-+ // Virtual memory.
-+ mib[0] = CTL_VM; mib[1] = VM_SWAPUSAGE;
-+ struct xsw_usage swap;
-+ len = sizeof(struct xsw_usage);
-+ if (sysctl(mib, miblen, &swap, &len, NULL, 0) == 0)
-+ {
-+ lpBuffer->ullAvailPageFile = swap.xsu_avail;
-+ lpBuffer->ullTotalVirtual = lpBuffer->ullTotalPhys + swap.xsu_total;
-+ }
-+
-+ // In use.
-+ mach_port_t stat_port = mach_host_self();
-+ vm_statistics_data_t vm_stat;
-+ mach_msg_type_number_t count = sizeof(vm_stat) / sizeof(natural_t);
-+ if (host_statistics(stat_port, HOST_VM_INFO, (host_info_t)&vm_stat, &count) == 0)
-+ {
-+ // Find page size.
-+ int pageSize;
-+ mib[0] = CTL_HW; mib[1] = HW_PAGESIZE;
-+ len = sizeof(int);
-+ if (sysctl(mib, miblen, &pageSize, &len, NULL, 0) == 0)
-+ {
-+ uint64_t used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pageSize;
-+
-+ lpBuffer->ullAvailPhys = lpBuffer->ullTotalPhys - used;
-+ lpBuffer->ullAvailVirtual = lpBuffer->ullAvailPhys; // FIXME.
-+ }
-+ }
-+#elif defined(__FreeBSD__)
-+ /* sysctl hw.physmem */
-+ size_t physmem = 0, mem_free = 0, pagesize = 0, swap_free = 0;
-+ size_t mem_avail = 0, mem_inactive = 0, mem_cache = 0, len = 0;
-+
-+ /* physmem */
-+ len = sizeof(physmem);
-+ if (sysctlbyname("hw.physmem", &physmem, &len, NULL, 0) == 0) {
-+ lpBuffer->ullTotalPhys = physmem;
-+ lpBuffer->ullTotalVirtual = physmem;
-+ }
-+ /* pagesize */
-+ len = sizeof(pagesize);
-+ if (sysctlbyname("hw.pagesize", &pagesize, &len, NULL, 0) != 0)
-+ pagesize = 4096;
-+ /* mem_inactive */
-+ len = sizeof(mem_inactive);
-+ if (sysctlbyname("vm.stats.vm.v_inactive_count", &mem_inactive, &len, NULL, 0) == 0)
-+ mem_inactive *= pagesize;
-+ /* mem_cache */
-+ len = sizeof(mem_cache);
-+ if (sysctlbyname("vm.stats.vm.v_cache_count", &mem_cache, &len, NULL, 0) == 0)
-+ mem_cache *= pagesize;
-+ /* mem_free */
-+ len = sizeof(mem_free);
-+ if (sysctlbyname("vm.stats.vm.v_free_count", &mem_free, &len, NULL, 0) == 0)
-+ mem_free *= pagesize;
-+
-+ /* mem_avail = mem_inactive + mem_cache + mem_free */
-+ lpBuffer->ullAvailPhys = mem_inactive + mem_cache + mem_free;
-+ lpBuffer->ullAvailVirtual = mem_inactive + mem_cache + mem_free;
-+
-+ if (sysctlbyname("vm.stats.vm.v_swappgsout", &swap_free, &len, NULL, 0) == 0)
-+ lpBuffer->ullAvailPageFile = swap_free * pagesize;
-+#else
-+ struct sysinfo info;
-+ char name[32];
-+ unsigned val;
-+ if (!procMeminfoFP && (procMeminfoFP = fopen("/proc/meminfo", "r")) == NULL)
-+ sysinfo(&info);
-+ else
-+ {
-+ memset(&info, 0, sizeof(struct sysinfo));
-+ info.mem_unit = 4096;
-+ while (fscanf(procMeminfoFP, "%31s %u%*[^\n]\n", name, &val) != EOF)
-+ {
-+ if (strncmp("MemTotal:", name, 9) == 0)
-+ info.totalram = val/4;
-+ else if (strncmp("MemFree:", name, 8) == 0)
-+ info.freeram = val/4;
-+ else if (strncmp("Buffers:", name, 8) == 0)
-+ info.bufferram += val/4;
-+ else if (strncmp("Cached:", name, 7) == 0)
-+ info.bufferram += val/4;
-+ else if (strncmp("SwapTotal:", name, 10) == 0)
-+ info.totalswap = val/4;
-+ else if (strncmp("SwapFree:", name, 9) == 0)
-+ info.freeswap = val/4;
-+ else if (strncmp("HighTotal:", name, 10) == 0)
-+ info.totalhigh = val/4;
-+ else if (strncmp("HighFree:", name, 9) == 0)
-+ info.freehigh = val/4;
-+ }
-+ rewind(procMeminfoFP);
-+ fflush(procMeminfoFP);
-+ }
-+ lpBuffer->ullAvailPageFile = (info.freeswap * info.mem_unit);
-+ lpBuffer->ullAvailPhys = ((info.freeram + info.bufferram) * info.mem_unit);
-+ lpBuffer->ullAvailVirtual = ((info.freeram + info.bufferram) * info.mem_unit);
-+ lpBuffer->ullTotalPhys = (info.totalram * info.mem_unit);
-+ lpBuffer->ullTotalVirtual = (info.totalram * info.mem_unit);
-+#endif
-+}
-+
-+#endif
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.h xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.h
---- xbmc-pvr-11.0.1/xbmc/linux/XMemUtils.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XMemUtils.h 2012-05-14 14:15:12.187221534 +0200
-@@ -22,10 +22,14 @@
- *
- */
-
-+#include "linux/PlatformDefs.h"
-+
- // aligned memory allocation and free. memory returned will be aligned to "alignTo" bytes.
- // this is a linux (actually platfom free) implementation of the win32 CRT methods _aligned_malloc and _aligned_free.
- void *_aligned_malloc(size_t s, size_t alignTo);
- void _aligned_free(void *p) ;
-
-+void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer);
-+
- #endif
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XSyncUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XSyncUtils.cpp 1970-01-01 01:00:00.000000000 +0100
-@@ -1,169 +0,0 @@
--/*
-- * Copyright (C) 2005-2008 Team XBMC
-- * http://www.xbmc.org
-- *
-- * This Program 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, or (at your option)
-- * any later version.
-- *
-- * This Program 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 XBMC; see the file COPYING. If not, write to
-- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#ifndef _WIN32
--
--
--#include
--#include
--#include
--#include
--#include
--#ifdef __APPLE__
--#include
--#endif
--
--#include "XSyncUtils.h"
--#include "XTimeUtils.h"
--#include "PlatformDefs.h"
--#include "XHandle.h"
--#include "XEventUtils.h"
--
--using namespace std;
--using namespace XbmcThreads;
--
--#include "../utils/log.h"
--#include "../utils/TimeUtils.h"
--
--#if defined(_LINUX) && !defined(__APPLE__) && !defined(__FreeBSD__)
--static FILE* procMeminfoFP = NULL;
--#endif
--
--void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer)
--{
-- if (!lpBuffer)
-- return;
--
-- memset(lpBuffer, 0, sizeof(MEMORYSTATUSEX));
--
--#ifdef __APPLE__
-- uint64_t physmem;
-- size_t len = sizeof physmem;
-- int mib[2] = { CTL_HW, HW_MEMSIZE };
-- size_t miblen = sizeof(mib) / sizeof(mib[0]);
--
-- // Total physical memory.
-- if (sysctl(mib, miblen, &physmem, &len, NULL, 0) == 0 && len == sizeof (physmem))
-- lpBuffer->ullTotalPhys = physmem;
--
-- // Virtual memory.
-- mib[0] = CTL_VM; mib[1] = VM_SWAPUSAGE;
-- struct xsw_usage swap;
-- len = sizeof(struct xsw_usage);
-- if (sysctl(mib, miblen, &swap, &len, NULL, 0) == 0)
-- {
-- lpBuffer->ullAvailPageFile = swap.xsu_avail;
-- lpBuffer->ullTotalVirtual = lpBuffer->ullTotalPhys + swap.xsu_total;
-- }
--
-- // In use.
-- mach_port_t stat_port = mach_host_self();
-- vm_statistics_data_t vm_stat;
-- mach_msg_type_number_t count = sizeof(vm_stat) / sizeof(natural_t);
-- if (host_statistics(stat_port, HOST_VM_INFO, (host_info_t)&vm_stat, &count) == 0)
-- {
-- // Find page size.
-- int pageSize;
-- mib[0] = CTL_HW; mib[1] = HW_PAGESIZE;
-- len = sizeof(int);
-- if (sysctl(mib, miblen, &pageSize, &len, NULL, 0) == 0)
-- {
-- uint64_t used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pageSize;
--
-- lpBuffer->ullAvailPhys = lpBuffer->ullTotalPhys - used;
-- lpBuffer->ullAvailVirtual = lpBuffer->ullAvailPhys; // FIXME.
-- }
-- }
--#elif defined(__FreeBSD__)
-- /* sysctl hw.physmem */
-- size_t physmem = 0, mem_free = 0, pagesize = 0, swap_free = 0;
-- size_t mem_avail = 0, mem_inactive = 0, mem_cache = 0, len = 0;
--
-- /* physmem */
-- len = sizeof(physmem);
-- if (sysctlbyname("hw.physmem", &physmem, &len, NULL, 0) == 0) {
-- lpBuffer->ullTotalPhys = physmem;
-- lpBuffer->ullTotalVirtual = physmem;
-- }
-- /* pagesize */
-- len = sizeof(pagesize);
-- if (sysctlbyname("hw.pagesize", &pagesize, &len, NULL, 0) != 0)
-- pagesize = 4096;
-- /* mem_inactive */
-- len = sizeof(mem_inactive);
-- if (sysctlbyname("vm.stats.vm.v_inactive_count", &mem_inactive, &len, NULL, 0) == 0)
-- mem_inactive *= pagesize;
-- /* mem_cache */
-- len = sizeof(mem_cache);
-- if (sysctlbyname("vm.stats.vm.v_cache_count", &mem_cache, &len, NULL, 0) == 0)
-- mem_cache *= pagesize;
-- /* mem_free */
-- len = sizeof(mem_free);
-- if (sysctlbyname("vm.stats.vm.v_free_count", &mem_free, &len, NULL, 0) == 0)
-- mem_free *= pagesize;
--
-- /* mem_avail = mem_inactive + mem_cache + mem_free */
-- lpBuffer->ullAvailPhys = mem_inactive + mem_cache + mem_free;
-- lpBuffer->ullAvailVirtual = mem_inactive + mem_cache + mem_free;
--
-- if (sysctlbyname("vm.stats.vm.v_swappgsout", &swap_free, &len, NULL, 0) == 0)
-- lpBuffer->ullAvailPageFile = swap_free * pagesize;
--#else
-- struct sysinfo info;
-- char name[32];
-- unsigned val;
-- if (!procMeminfoFP && (procMeminfoFP = fopen("/proc/meminfo", "r")) == NULL)
-- sysinfo(&info);
-- else
-- {
-- memset(&info, 0, sizeof(struct sysinfo));
-- info.mem_unit = 4096;
-- while (fscanf(procMeminfoFP, "%31s %u%*[^\n]\n", name, &val) != EOF)
-- {
-- if (strncmp("MemTotal:", name, 9) == 0)
-- info.totalram = val/4;
-- else if (strncmp("MemFree:", name, 8) == 0)
-- info.freeram = val/4;
-- else if (strncmp("Buffers:", name, 8) == 0)
-- info.bufferram += val/4;
-- else if (strncmp("Cached:", name, 7) == 0)
-- info.bufferram += val/4;
-- else if (strncmp("SwapTotal:", name, 10) == 0)
-- info.totalswap = val/4;
-- else if (strncmp("SwapFree:", name, 9) == 0)
-- info.freeswap = val/4;
-- else if (strncmp("HighTotal:", name, 10) == 0)
-- info.totalhigh = val/4;
-- else if (strncmp("HighFree:", name, 9) == 0)
-- info.freehigh = val/4;
-- }
-- rewind(procMeminfoFP);
-- fflush(procMeminfoFP);
-- }
-- lpBuffer->ullAvailPageFile = (info.freeswap * info.mem_unit);
-- lpBuffer->ullAvailPhys = ((info.freeram + info.bufferram) * info.mem_unit);
-- lpBuffer->ullAvailVirtual = ((info.freeram + info.bufferram) * info.mem_unit);
-- lpBuffer->ullTotalPhys = (info.totalram * info.mem_unit);
-- lpBuffer->ullTotalVirtual = (info.totalram * info.mem_unit);
--#endif
--}
--
--#endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.h xbmc-pvr-11.0.1.patch/xbmc/linux/XSyncUtils.h
---- xbmc-pvr-11.0.1/xbmc/linux/XSyncUtils.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XSyncUtils.h 1970-01-01 01:00:00.000000000 +0100
-@@ -1,44 +0,0 @@
--#ifndef __X_SYNC_UTILS_
--#define __X_SYNC_UTILS_
--
--/*
-- * Copyright (C) 2005-2008 Team XBMC
-- * http://www.xbmc.org
-- *
-- * This Program 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, or (at your option)
-- * any later version.
-- *
-- * This Program 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 XBMC; see the file COPYING. If not, write to
-- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#include "PlatformDefs.h"
--#include "XHandlePublic.h"
--
--#ifdef _LINUX
--
--#define STATUS_WAIT_0 ((DWORD )0x00000000L)
--#define WAIT_FAILED ((DWORD)0xFFFFFFFF)
--#define WAIT_OBJECT_0 ((STATUS_WAIT_0 ) + 0 )
--#define WAIT_TIMEOUT 258L
--#define INFINITE 0xFFFFFFFF
--#define STATUS_ABANDONED_WAIT_0 0x00000080
--#define WAIT_ABANDONED ((STATUS_ABANDONED_WAIT_0 ) + 0 )
--#define WAIT_ABANDONED_0 ((STATUS_ABANDONED_WAIT_0 ) + 0 )
--
--void GlobalMemoryStatusEx(LPMEMORYSTATUSEX lpBuffer);
--
--#endif
--
--#endif
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/linux/XThreadUtils.cpp xbmc-pvr-11.0.1.patch/xbmc/linux/XThreadUtils.cpp
---- xbmc-pvr-11.0.1/xbmc/linux/XThreadUtils.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/linux/XThreadUtils.cpp 1970-01-01 01:00:00.000000000 +0100
-@@ -1,210 +0,0 @@
--/*
-- * Copyright (C) 2005-2009 Team XBMC
-- * http://www.xbmc.org
-- *
-- * This Program 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, or (at your option)
-- * any later version.
-- *
-- * This Program 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 XBMC; see the file COPYING. If not, write to
-- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-- * http://www.gnu.org/copyleft/gpl.html
-- *
-- */
--
--#include "PlatformDefs.h"
--#include "XHandle.h"
--#include "XThreadUtils.h"
--#include "XTimeUtils.h"
--#include "XEventUtils.h"
--#include "system.h"
--#include "utils/log.h"
--
--#ifdef _LINUX
--#include
--#include
--#include
--
--HANDLE WINAPI CreateThread(
-- LPSECURITY_ATTRIBUTES lpThreadAttributes,
-- SIZE_T dwStackSize,
-- LPTHREAD_START_ROUTINE lpStartAddress,
-- LPVOID lpParameter,
-- DWORD dwCreationFlags,
-- LPDWORD lpThreadId
-- ) {
--
-- // a thread handle would actually contain an event
-- // the event would mark if the thread is running or not. it will be used in the Wait functions.
-- HANDLE h = CreateEvent(NULL, TRUE, FALSE, NULL);
-- h->ChangeType(CXHandle::HND_THREAD);
--#ifdef __APPLE__
-- h->m_machThreadPort = MACH_PORT_NULL;
--#endif
-- pthread_attr_t attr;
-- pthread_attr_init(&attr);
-- if (dwStackSize > PTHREAD_STACK_MIN)
-- pthread_attr_setstacksize(&attr, dwStackSize);
-- if (pthread_create(&(h->m_hThread), &attr, (void*(*)(void*))lpStartAddress, lpParameter) == 0)
-- h->m_threadValid = true;
-- else
-- {
-- CloseHandle(h);
-- h = NULL;
-- }
-- pthread_attr_destroy(&attr);
--
-- if (h && lpThreadId)
-- // WARNING: This can truncate thread IDs on x86_64.
-- *lpThreadId = (DWORD)h->m_hThread;
-- return h;
--}
--
--
--#if 0 // Deprecated, use CThread::GetCurrentThreadId() instead
--DWORD WINAPI GetCurrentThreadId(void) {
-- // WARNING: This can truncate thread IDs on x86_64.
-- return (DWORD)pthread_self();
--}
--#endif
--
--HANDLE WINAPI GetCurrentThread(void) {
-- return (HANDLE)-1; // -1 a special value - pseudo handle
--}
--
--HANDLE WINAPI GetCurrentProcess(void) {
-- return (HANDLE)-1; // -1 a special value - pseudo handle
--}
--
--HANDLE _beginthreadex(
-- void *security,
-- unsigned stack_size,
-- int ( *start_address )( void * ),
-- void *arglist,
-- unsigned initflag,
-- unsigned *thrdaddr
--) {
--
-- HANDLE h = CreateThread(NULL, stack_size, start_address, arglist, initflag, (LPDWORD)thrdaddr);
-- return h;
--
--}
--
--uintptr_t _beginthread(
-- void( *start_address )( void * ),
-- unsigned stack_size,
-- void *arglist
--) {
-- HANDLE h = CreateThread(NULL, stack_size, (LPTHREAD_START_ROUTINE)start_address, arglist, 0, NULL);
-- return (uintptr_t)h;
--}
--
--BOOL WINAPI GetThreadTimes (
-- HANDLE hThread,
-- LPFILETIME lpCreationTime,
-- LPFILETIME lpExitTime,
-- LPFILETIME lpKernelTime,
-- LPFILETIME lpUserTime
--) {
-- if (!hThread)
-- return false;
-- if (!hThread->m_threadValid)
-- return false;
--
-- if (hThread == (HANDLE)-1) {
-- if (lpCreationTime)
-- TimeTToFileTime(0,lpCreationTime);
-- if (lpExitTime)
-- TimeTToFileTime(time(NULL),lpExitTime);
-- if (lpKernelTime)
-- TimeTToFileTime(0,lpKernelTime);
-- if (lpUserTime)
-- TimeTToFileTime(0,lpUserTime);
--
-- return true;
-- }
--
-- if (lpCreationTime)
-- TimeTToFileTime(hThread->m_tmCreation,lpCreationTime);
-- if (lpExitTime)
-- TimeTToFileTime(time(NULL),lpExitTime);
-- if (lpKernelTime)
-- TimeTToFileTime(0,lpKernelTime);
--
--#ifdef __APPLE__
-- thread_info_data_t threadInfo;
-- mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX;
--
-- if (hThread->m_machThreadPort == MACH_PORT_NULL)
-- hThread->m_machThreadPort = pthread_mach_thread_np(hThread->m_hThread);
--
-- kern_return_t ret = thread_info(hThread->m_machThreadPort, THREAD_BASIC_INFO, (thread_info_t)threadInfo, &threadInfoCount);
-- if (ret == KERN_SUCCESS)
-- {
-- thread_basic_info_t threadBasicInfo = (thread_basic_info_t)threadInfo;
--
-- if (lpUserTime)
-- {
-- // User time.
-- unsigned long long time = ((__int64)threadBasicInfo->user_time.seconds * 10000000L) + threadBasicInfo->user_time.microseconds*10L;
-- lpUserTime->dwLowDateTime = (time & 0xFFFFFFFF);
-- lpUserTime->dwHighDateTime = (time >> 32);
-- }
--
-- if (lpKernelTime)
-- {
-- // System time.
-- unsigned long long time = ((__int64)threadBasicInfo->system_time.seconds * 10000000L) + threadBasicInfo->system_time.microseconds*10L;
-- lpKernelTime->dwLowDateTime = (time & 0xFFFFFFFF);
-- lpKernelTime->dwHighDateTime = (time >> 32);
-- }
-- }
-- else
-- {
-- if (lpUserTime)
-- lpUserTime->dwLowDateTime = lpUserTime->dwHighDateTime = 0;
--
-- if (lpKernelTime)
-- lpKernelTime->dwLowDateTime = lpKernelTime->dwHighDateTime = 0;
-- }
--#elif _POSIX_THREAD_CPUTIME != -1
-- if(lpUserTime)
-- {
-- lpUserTime->dwLowDateTime = 0;
-- lpUserTime->dwHighDateTime = 0;
-- clockid_t clock;
-- if (pthread_getcpuclockid(hThread->m_hThread, &clock) == 0)
-- {
-- struct timespec tp = {};
-- clock_gettime(clock, &tp);
-- unsigned long long time = (unsigned long long)tp.tv_sec * 10000000 + (unsigned long long)tp.tv_nsec/100;
-- lpUserTime->dwLowDateTime = (time & 0xFFFFFFFF);
-- lpUserTime->dwHighDateTime = (time >> 32);
-- }
-- }
--#else
-- if (lpUserTime)
-- TimeTToFileTime(0,lpUserTime);
--#endif
-- return true;
--}
--
--BOOL WINAPI SetThreadPriority(HANDLE hThread, int nPriority)
--{
-- return true;
--}
--
--int GetThreadPriority(HANDLE hThread)
--{
-- return 0;
--}
--
--#endif
--
-diff -Naur xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScanner.cpp xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScanner.cpp
---- xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScanner.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScanner.cpp 2012-05-14 14:15:12.192221636 +0200
-@@ -57,7 +57,7 @@
- using namespace XFILE;
- using namespace MUSIC_GRABBER;
-
--CMusicInfoScanner::CMusicInfoScanner()
-+CMusicInfoScanner::CMusicInfoScanner() : CThread("CMusicInfoScanner")
- {
- m_bRunning = false;
- m_pObserver = NULL;
-@@ -99,7 +99,7 @@
-
- // Create the thread to count all files to be scanned
- SetPriority( GetMinPriority() );
-- CThread fileCountReader(this);
-+ CThread fileCountReader(this, "CMusicInfoScanner");
- if (m_pObserver)
- fileCountReader.Create();
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScraper.cpp xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScraper.cpp
---- xbmc-pvr-11.0.1/xbmc/music/infoscanner/MusicInfoScraper.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/music/infoscanner/MusicInfoScraper.cpp 2012-05-14 14:15:12.192221636 +0200
-@@ -28,7 +28,7 @@
- using namespace ADDON;
- using namespace std;
-
--CMusicInfoScraper::CMusicInfoScraper(const ADDON::ScraperPtr &scraper)
-+CMusicInfoScraper::CMusicInfoScraper(const ADDON::ScraperPtr &scraper) : CThread("CMusicInfoScraper")
- {
- m_bSucceeded=false;
- m_bCanceled=false;
-diff -Naur xbmc-pvr-11.0.1/xbmc/music/LastFmManager.cpp xbmc-pvr-11.0.1.patch/xbmc/music/LastFmManager.cpp
---- xbmc-pvr-11.0.1/xbmc/music/LastFmManager.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/music/LastFmManager.cpp 2012-05-14 14:15:12.193221656 +0200
-@@ -70,7 +70,7 @@
-
- CLastFmManager* CLastFmManager::m_pInstance=NULL;
-
--CLastFmManager::CLastFmManager()
-+CLastFmManager::CLastFmManager() : CThread("CLastFmManager")
- {
- m_RadioTrackQueue = new CPlayList;
- }
-@@ -534,7 +534,7 @@
- if (iNrCachedTracks == 0)
- {
- //get more tracks
-- if (ThreadHandle() != NULL)
-+ if (IsRunning())
- {
- m_hWorkerEvent.Set();
- }
-@@ -633,7 +633,7 @@
- {
- m_RadioSession = "";
- }
-- if (m_ThreadHandle)
-+ if (IsRunning())
- {
- m_bStop = true;
- m_hWorkerEvent.Set();
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/AirPlayServer.cpp xbmc-pvr-11.0.1.patch/xbmc/network/AirPlayServer.cpp
---- xbmc-pvr-11.0.1/xbmc/network/AirPlayServer.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/AirPlayServer.cpp 2012-05-14 14:15:12.194221676 +0200
-@@ -184,7 +184,7 @@
- }
- }
-
--CAirPlayServer::CAirPlayServer(int port, bool nonlocal)
-+CAirPlayServer::CAirPlayServer(int port, bool nonlocal) : CThread("AirPlayServer")
- {
- m_port = port;
- m_nonlocal = nonlocal;
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/AirTunesServer.cpp xbmc-pvr-11.0.1.patch/xbmc/network/AirTunesServer.cpp
---- xbmc-pvr-11.0.1/xbmc/network/AirTunesServer.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/AirTunesServer.cpp 2012-05-14 14:15:12.195221696 +0200
-@@ -292,7 +292,7 @@
- }
- }
-
--CAirTunesServer::CAirTunesServer(int port, bool nonlocal)
-+CAirTunesServer::CAirTunesServer(int port, bool nonlocal) : CThread("CAirTunesServer")
- {
- m_port = port;
- m_pLibShairport = new DllLibShairport();
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/libscrobbler/scrobbler.cpp xbmc-pvr-11.0.1.patch/xbmc/network/libscrobbler/scrobbler.cpp
---- xbmc-pvr-11.0.1/xbmc/network/libscrobbler/scrobbler.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/libscrobbler/scrobbler.cpp 2012-05-14 14:15:12.196221716 +0200
-@@ -46,7 +46,7 @@
- #define SCROBBLER_ACTION_NOWPLAYING 2
-
- CScrobbler::CScrobbler(const CStdString &strHandshakeURL, const CStdString &strLogPrefix)
-- : CThread()
-+ : CThread("CScrobbler")
- {
- m_bBanned = false;
- m_bBadAuth = false;
-@@ -67,7 +67,7 @@
- ResetState();
- LoadCredentials();
- LoadJournal();
-- if (!ThreadHandle())
-+ if (!IsRunning())
- Create();
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/Network.h xbmc-pvr-11.0.1.patch/xbmc/network/Network.h
---- xbmc-pvr-11.0.1/xbmc/network/Network.h 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/Network.h 2012-05-14 14:15:12.197221736 +0200
-@@ -24,6 +24,7 @@
-
- #include
- #include "utils/StdString.h"
-+#include "system.h"
-
- enum EncMode { ENC_NONE = 0, ENC_WEP = 1, ENC_WPA = 2, ENC_WPA2 = 3 };
- enum NetworkAssignment { NETWORK_DASH = 0, NETWORK_DHCP = 1, NETWORK_STATIC = 2, NETWORK_DISABLED = 3 };
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/TCPServer.cpp xbmc-pvr-11.0.1.patch/xbmc/network/TCPServer.cpp
---- xbmc-pvr-11.0.1/xbmc/network/TCPServer.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/TCPServer.cpp 2012-05-14 14:15:12.197221736 +0200
-@@ -85,7 +85,7 @@
- }
- }
-
--CTCPServer::CTCPServer(int port, bool nonlocal)
-+CTCPServer::CTCPServer(int port, bool nonlocal) : CThread("CTCPServer")
- {
- m_port = port;
- m_nonlocal = nonlocal;
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/UdpClient.cpp xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.cpp
---- xbmc-pvr-11.0.1/xbmc/network/UdpClient.cpp 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.cpp 2012-05-14 14:15:12.198221756 +0200
-@@ -35,7 +35,7 @@
-
- #define UDPCLIENT_DEBUG_LEVEL LOGDEBUG
-
--CUdpClient::CUdpClient(void) : CThread()
-+CUdpClient::CUdpClient(void) : CThread("CUdpClient")
- {}
-
- CUdpClient::~CUdpClient(void)
-diff -Naur xbmc-pvr-11.0.1/xbmc/network/UdpClient.h xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.h
---- xbmc-pvr-11.0.1/xbmc/network/UdpClient.h 2012-03-27 17:55:33.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/network/UdpClient.h 2012-05-14 14:15:12.199221776 +0200
-@@ -25,6 +25,7 @@
- #include "threads/CriticalSection.h"
- #include
- #include
-+#include "system.h"
-
- class CUdpClient : CThread
- {
-diff -Naur xbmc-pvr-11.0.1/xbmc/peripherals/Peripherals.cpp xbmc-pvr-11.0.1.patch/xbmc/peripherals/Peripherals.cpp
---- xbmc-pvr-11.0.1/xbmc/peripherals/Peripherals.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/peripherals/Peripherals.cpp 2012-05-14 14:15:12.199221776 +0200
-@@ -19,6 +19,7 @@
- *
- */
-
-+#include "system.h"
- #include "Peripherals.h"
- #include "bus/PeripheralBus.h"
- #include "devices/PeripheralBluetooth.h"
-diff -Naur xbmc-pvr-11.0.1/xbmc/pictures/GUIWindowSlideShow.cpp xbmc-pvr-11.0.1.patch/xbmc/pictures/GUIWindowSlideShow.cpp
---- xbmc-pvr-11.0.1/xbmc/pictures/GUIWindowSlideShow.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/pictures/GUIWindowSlideShow.cpp 2012-05-14 14:15:12.201221817 +0200
-@@ -67,7 +67,7 @@
-
- static float zoomamount[10] = { 1.0f, 1.2f, 1.5f, 2.0f, 2.8f, 4.0f, 6.0f, 9.0f, 13.5f, 20.0f };
-
--CBackgroundPicLoader::CBackgroundPicLoader()
-+CBackgroundPicLoader::CBackgroundPicLoader() : CThread("CBackgroundPicLoader")
- {
- m_pCallback = NULL;
- m_isLoading = false;
-diff -Naur xbmc-pvr-11.0.1/xbmc/rendering/dx/RenderSystemDX.cpp xbmc-pvr-11.0.1.patch/xbmc/rendering/dx/RenderSystemDX.cpp
---- xbmc-pvr-11.0.1/xbmc/rendering/dx/RenderSystemDX.cpp 2012-03-27 17:55:35.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/rendering/dx/RenderSystemDX.cpp 2012-05-14 14:15:12.202221838 +0200
-@@ -569,7 +569,7 @@
-
- //CVideoReferenceClock polls GetRasterStatus too,
- //polling it from two threads at the same time is bad
-- if (g_advancedSettings.m_sleepBeforeFlip > 0 && g_VideoReferenceClock.ThreadHandle() == NULL)
-+ if (g_advancedSettings.m_sleepBeforeFlip > 0 && !g_VideoReferenceClock.IsRunning())
- {
- //save current thread priority and set thread priority to THREAD_PRIORITY_TIME_CRITICAL
- int priority = GetThreadPriority(GetCurrentThread());
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.cpp xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.cpp
---- xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.cpp 2012-05-14 14:15:12.203221858 +0200
-@@ -96,12 +96,18 @@
- m_videoAllowMpeg4VAAPI = false;
- m_videoDisableBackgroundDeinterlace = false;
- m_videoCaptureUseOcclusionQuery = -1; //-1 is auto detect
-+ m_videoVDPAUdeintHD = -1;
-+ m_videoVDPAUdeintSD = -1;
-+ m_videoVDPAUtelecine = false;
-+ m_videoVDPAUmaxHeight = -1;
-+ m_videoVDPAUdeintSkipChromaHD = false;
- m_DXVACheckCompatibility = false;
- m_DXVACheckCompatibilityPresent = false;
- m_DXVAForceProcessorRenderer = true;
- m_DXVANoDeintProcForProgressive = false;
- m_videoFpsDetect = 1;
- m_videoDefaultLatency = 0.0;
-+ m_vblankPolling = false;
-
- m_musicUseTimeSeeking = true;
- m_musicTimeSeekForward = 10;
-@@ -470,6 +476,11 @@
- XMLUtils::GetBoolean(pElement,"allowmpeg4vaapi",m_videoAllowMpeg4VAAPI);
- XMLUtils::GetBoolean(pElement, "disablebackgrounddeinterlace", m_videoDisableBackgroundDeinterlace);
- XMLUtils::GetInt(pElement, "useocclusionquery", m_videoCaptureUseOcclusionQuery, -1, 1);
-+ XMLUtils::GetInt(pElement,"vdpauHDdeint",m_videoVDPAUdeintHD);
-+ XMLUtils::GetInt(pElement,"vdpauSDdeint",m_videoVDPAUdeintSD);
-+ XMLUtils::GetInt(pElement,"vdpauMaxHeight",m_videoVDPAUmaxHeight);
-+ XMLUtils::GetBoolean(pElement,"vdpauInvTelecine",m_videoVDPAUtelecine);
-+ XMLUtils::GetBoolean(pElement,"vdpauHDdeintSkipChroma",m_videoVDPAUdeintSkipChromaHD);
-
- TiXmlElement* pAdjustRefreshrate = pElement->FirstChildElement("adjustrefreshrate");
- if (pAdjustRefreshrate)
-@@ -559,6 +570,8 @@
- //0 = disable fps detect, 1 = only detect on timestamps with uniform spacing, 2 detect on all timestamps
- XMLUtils::GetInt(pElement, "fpsdetect", m_videoFpsDetect, 0, 2);
-
-+ XMLUtils::GetBoolean(pElement,"vblankpolling", m_vblankPolling);
-+
- // Store global display latency settings
- TiXmlElement* pVideoLatency = pElement->FirstChildElement("latency");
- if (pVideoLatency)
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.h xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.h
---- xbmc-pvr-11.0.1/xbmc/settings/AdvancedSettings.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/AdvancedSettings.h 2012-05-14 14:15:12.204221878 +0200
-@@ -111,6 +111,11 @@
- int m_videoPercentSeekBackwardBig;
- CStdString m_videoPPFFmpegDeint;
- CStdString m_videoPPFFmpegPostProc;
-+ int m_videoVDPAUdeintHD;
-+ int m_videoVDPAUdeintSD;
-+ bool m_videoVDPAUtelecine;
-+ int m_videoVDPAUmaxHeight;
-+ bool m_videoVDPAUdeintSkipChromaHD;
- bool m_musicUseTimeSeeking;
- int m_musicTimeSeekForward;
- int m_musicTimeSeekBackward;
-@@ -143,6 +148,7 @@
- bool m_DXVAForceProcessorRenderer;
- bool m_DXVANoDeintProcForProgressive;
- int m_videoFpsDetect;
-+ bool m_vblankPolling;
-
- CStdString m_videoDefaultPlayer;
- CStdString m_videoDefaultDVDPlayer;
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/GUISettings.cpp xbmc-pvr-11.0.1.patch/xbmc/settings/GUISettings.cpp
---- xbmc-pvr-11.0.1/xbmc/settings/GUISettings.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/GUISettings.cpp 2012-05-14 14:15:12.205221898 +0200
-@@ -588,10 +588,15 @@
-
- #ifdef HAVE_LIBVDPAU
- AddBool(vp, "videoplayer.usevdpau", 13425, true);
-+ AddBool(vp, "videoplayer.usevdpauinteroprgb", 13433, true);
-+ AddBool(vp, "videoplayer.usevdpauinteropyuv", 13434, true);
- #endif
- #ifdef HAVE_LIBVA
- AddBool(vp, "videoplayer.usevaapi", 13426, true);
- #endif
-+#ifdef HAVE_LIBXVBA
-+ AddBool(vp, "videoplayer.usexvba", 13435, true);
-+#endif
- #ifdef HAS_DX
- AddBool(g_sysinfo.IsVistaOrHigher() ? vp: NULL, "videoplayer.usedxva2", 13427, g_sysinfo.IsVistaOrHigher() ? true : false);
- #endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp xbmc-pvr-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp
---- xbmc-pvr-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-05-14 14:15:12.207221938 +0200
-@@ -557,6 +557,40 @@
- pControl->SetEnabled(true);
- }
- }
-+ else if (strSetting.Equals("videoplayer.usevdpauinteropyuv"))
-+ {
-+ bool hasInterop = false;
-+#ifdef GL_NV_vdpau_interop
-+ hasInterop = true;
-+#endif
-+ CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
-+ if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
-+ {
-+ pControl->SetEnabled(true);
-+ }
-+ else
-+ {
-+ pControl->SetEnabled(false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
-+ }
-+ }
-+ else if (strSetting.Equals("videoplayer.usevdpauinteroprgb"))
-+ {
-+ bool hasInterop = false;
-+#ifdef GL_NV_vdpau_interop
-+ hasInterop = true;
-+#endif
-+ CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
-+ if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
-+ {
-+ pControl->SetEnabled(true);
-+ }
-+ else
-+ {
-+ pControl->SetEnabled(false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
-+ }
-+ }
- else
- #endif
- if (strSetting.Equals("videoscreen.resolution"))
-diff -Naur xbmc-pvr-11.0.1/xbmc/settings/VideoSettings.h xbmc-pvr-11.0.1.patch/xbmc/settings/VideoSettings.h
---- xbmc-pvr-11.0.1/xbmc/settings/VideoSettings.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/settings/VideoSettings.h 2012-05-14 14:15:12.208221958 +0200
-@@ -66,6 +66,8 @@
- VS_INTERLACEMETHOD_SW_BLEND = 20,
- VS_INTERLACEMETHOD_AUTO_ION = 21,
-
-+ VS_INTERLACEMETHOD_XVBA = 22,
-+
- VS_INTERLACEMETHOD_MAX // do not use and keep as last enum value.
- };
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/darwin/ThreadSchedImpl.cpp 2012-05-14 14:15:12.208221958 +0200
-@@ -0,0 +1,47 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+int CThread::GetSchedRRPriority(void)
-+{
-+ return 96;
-+}
-+
-+bool CThread::SetPrioritySched_RR(int iPriority)
-+{
-+ // Changing to SCHED_RR is safe under OSX, you don't need elevated privileges and the
-+ // OSX scheduler will monitor SCHED_RR threads and drop to SCHED_OTHER if it detects
-+ // the thread running away. OSX automatically does this with the CoreAudio audio
-+ // device handler thread.
-+ int32_t result;
-+ thread_extended_policy_data_t theFixedPolicy;
-+
-+ // make thread fixed, set to 'true' for a non-fixed thread
-+ theFixedPolicy.timeshare = false;
-+ result = thread_policy_set(pthread_mach_thread_np(ThreadId()), THREAD_EXTENDED_POLICY,
-+ (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
-+
-+ int policy;
-+ struct sched_param param;
-+ result = pthread_getschedparam(ThreadId(), &policy, ¶m );
-+ // change from default SCHED_OTHER to SCHED_RR
-+ policy = SCHED_RR;
-+ result = pthread_setschedparam(ThreadId(), policy, ¶m );
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/linux/ThreadSchedImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/linux/ThreadSchedImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/linux/ThreadSchedImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/linux/ThreadSchedImpl.cpp 2012-05-14 14:15:12.209221978 +0200
-@@ -0,0 +1,30 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+int CThread::GetSchedRRPriority(void)
-+{
-+ return GetNormalPriority();
-+}
-+
-+bool CThread::SetPrioritySched_RR(int iPriority)
-+{
-+ return false;
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.cpp 2012-05-14 14:15:12.210221998 +0200
-@@ -0,0 +1,220 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#include
-+#include
-+#include
-+#include
-+
-+void CThread::Create(bool bAutoDelete, unsigned stacksize)
-+{
-+ if (m_ThreadId != 0)
-+ {
-+ CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
-+ exit(1);
-+ }
-+ m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
-+ m_iLastUsage = 0;
-+ m_fLastUsage = 0.0f;
-+ m_bAutoDelete = bAutoDelete;
-+ m_bStop = false;
-+ m_StopEvent.Reset();
-+ m_TermEvent.Reset();
-+ m_StartEvent.Reset();
-+
-+ pthread_attr_t attr;
-+ pthread_attr_init(&attr);
-+ if (stacksize > PTHREAD_STACK_MIN)
-+ pthread_attr_setstacksize(&attr, stacksize);
-+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-+ if (pthread_create(&m_ThreadId, &attr, (void*(*)(void*))staticThread, this) != 0)
-+ {
-+ CLog::Log(LOGNOTICE, "%s - fatal error creating thread",__FUNCTION__);
-+ }
-+ pthread_attr_destroy(&attr);
-+}
-+
-+void CThread::TermHandler()
-+{
-+
-+}
-+
-+void CThread::SetThreadInfo()
-+{
-+ m_ThreadOpaque.LwpId = syscall(SYS_gettid);
-+
-+ // start thread with nice level of appication
-+ int appNice = getpriority(PRIO_PROCESS, getpid());
-+ if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, appNice) != 0)
-+ CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
-+}
-+
-+ThreadIdentifier CThread::GetCurrentThreadId()
-+{
-+ return pthread_self();
-+}
-+
-+bool CThread::IsCurrentThread(const ThreadIdentifier tid)
-+{
-+ return pthread_equal(pthread_self(), tid);
-+}
-+
-+int CThread::GetMinPriority(void)
-+{
-+ // one level lower than application
-+ return -1;
-+}
-+
-+int CThread::GetMaxPriority(void)
-+{
-+ // one level higher than application
-+ return 1;
-+}
-+
-+int CThread::GetNormalPriority(void)
-+{
-+ // same level as application
-+ return 0;
-+}
-+
-+bool CThread::SetPriority(const int iPriority)
-+{
-+ bool bReturn = false;
-+
-+ // wait until thread is running, it needs to get its lwp id
-+ m_StartEvent.Wait();
-+
-+ CSingleLock lock(m_CriticalSection);
-+
-+ // get min prio for SCHED_RR
-+ int minRR = GetMaxPriority() + 1;
-+
-+ if (!m_ThreadId)
-+ bReturn = false;
-+ else if (iPriority >= minRR)
-+ bReturn = SetPrioritySched_RR(iPriority);
-+ else
-+ {
-+ // get user max prio
-+ struct rlimit limit;
-+ int userMaxPrio;
-+ if (getrlimit(RLIMIT_NICE, &limit) == 0)
-+ {
-+ userMaxPrio = limit.rlim_cur - 20;
-+ }
-+ else
-+ userMaxPrio = 0;
-+
-+ // keep priority in bounds
-+ int prio = iPriority;
-+ if (prio >= GetMaxPriority())
-+ prio = std::min(GetMaxPriority(), userMaxPrio);
-+ if (prio < GetMinPriority())
-+ prio = GetMinPriority();
-+
-+ // nice level of application
-+ int appNice = getpriority(PRIO_PROCESS, getpid());
-+ if (prio)
-+ prio = prio > 0 ? appNice-1 : appNice+1;
-+
-+ if (setpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId, prio) == 0)
-+ bReturn = true;
-+ else
-+ CLog::Log(LOGERROR, "%s: error %s", __FUNCTION__, strerror(errno));
-+ }
-+
-+ return bReturn;
-+}
-+
-+int CThread::GetPriority()
-+{
-+ int iReturn;
-+
-+ // lwp id is valid after start signel has fired
-+ m_StartEvent.Wait();
-+
-+ CSingleLock lock(m_CriticalSection);
-+
-+ int appNice = getpriority(PRIO_PROCESS, getpid());
-+ int prio = getpriority(PRIO_PROCESS, m_ThreadOpaque.LwpId);
-+ iReturn = appNice - prio;
-+
-+ return iReturn;
-+}
-+
-+bool CThread::WaitForThreadExit(unsigned int milliseconds)
-+{
-+ bool bReturn = m_TermEvent.WaitMSec(milliseconds);
-+
-+ return bReturn;
-+}
-+
-+int64_t CThread::GetAbsoluteUsage()
-+{
-+ CSingleLock lock(m_CriticalSection);
-+
-+ if (!m_ThreadId)
-+ return 0;
-+
-+ clockid_t clock;
-+ int64_t time = 0;
-+ if (pthread_getcpuclockid(m_ThreadId, &clock) == 0)
-+ {
-+ struct timespec tp;
-+ clock_gettime(clock, &tp);
-+ time = (int64_t)tp.tv_sec * 10000000 + tp.tv_nsec/100;
-+ }
-+ return time;
-+}
-+
-+float CThread::GetRelativeUsage()
-+{
-+ unsigned int iTime = XbmcThreads::SystemClockMillis();
-+ iTime *= 10000; // convert into 100ns tics
-+
-+ // only update every 1 second
-+ if( iTime < m_iLastTime + 1000*10000 ) return m_fLastUsage;
-+
-+ int64_t iUsage = GetAbsoluteUsage();
-+
-+ if (m_iLastUsage > 0 && m_iLastTime > 0)
-+ m_fLastUsage = (float)( iUsage - m_iLastUsage ) / (float)( iTime - m_iLastTime );
-+
-+ m_iLastUsage = iUsage;
-+ m_iLastTime = iTime;
-+
-+ return m_fLastUsage;
-+}
-+
-+int64_t CThread::GetCurrentThreadUsage()
-+{
-+ pthread_t tid = pthread_self();
-+ clockid_t clock;
-+ int64_t time = 0;
-+ if (pthread_getcpuclockid(tid, &clock) == 0)
-+ {
-+ struct timespec tp;
-+ clock_gettime(clock, &tp);
-+ time = (int64_t)tp.tv_sec * 10000000 + tp.tv_nsec/100;
-+ }
-+ return time;
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h 2012-05-14 14:15:12.210221998 +0200
-@@ -0,0 +1,39 @@
-+/*
-+* Copyright (C) 2005-2011 Team XBMC
-+* http://www.xbmc.org
-+*
-+* This Program 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, or (at your option)
-+* any later version.
-+*
-+* This Program 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 XBMC; see the file COPYING. If not, write to
-+* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+* http://www.gnu.org/copyleft/gpl.html
-+*
-+*/
-+
-+#pragma once
-+
-+#include
-+
-+struct threadOpaque
-+{
-+ pid_t LwpId;
-+};
-+
-+typedef pthread_t ThreadIdentifier;
-+typedef threadOpaque ThreadOpaque;
-+typedef int THREADFUNC;
-+
-+namespace XbmcThreads
-+{
-+ inline static void ThreadSleep(unsigned int millis) { usleep(millis*1000); }
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.cpp 2012-05-14 14:15:12.211222019 +0200
-@@ -0,0 +1,34 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#pragma once
-+
-+#if (defined TARGET_POSIX)
-+#include "threads/platform/pthreads/ThreadImpl.cpp"
-+#if defined(TARGET_DARWIN_IOS)
-+#include "threads/platform/darwin/ThreadSchedImpl.cpp"
-+#else
-+#include "threads/platform/linux/ThreadSchedImpl.cpp"
-+#endif
-+#elif (defined TARGET_WINDOWS)
-+#include "threads/platform/win/ThreadImpl.cpp"
-+#endif
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/platform/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/ThreadImpl.h 2012-05-14 14:15:12.211222019 +0200
-@@ -0,0 +1,28 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#pragma once
-+
-+#if (defined TARGET_POSIX)
-+#include "threads/platform/pthreads/ThreadImpl.h"
-+#elif (defined TARGET_WINDOWS)
-+#include "threads/platform/win/ThreadImpl.h"
-+#endif
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.cpp 2012-05-14 14:15:12.212222039 +0200
-@@ -0,0 +1,207 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#include
-+
-+
-+void CThread::Create(bool bAutoDelete, unsigned stacksize)
-+{
-+ if (m_ThreadId != 0)
-+ {
-+ CLog::Log(LOGERROR, "%s - fatal error creating thread- old thread id not null", __FUNCTION__);
-+ exit(1);
-+ }
-+ m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
-+ m_iLastUsage = 0;
-+ m_fLastUsage = 0.0f;
-+ m_bAutoDelete = bAutoDelete;
-+ m_bStop = false;
-+ m_StopEvent.Reset();
-+ m_TermEvent.Reset();
-+ m_StartEvent.Reset();
-+
-+ m_ThreadOpaque.handle = CreateThread(NULL,stacksize, (LPTHREAD_START_ROUTINE)&staticThread, this, 0, &m_ThreadId);
-+ if (m_ThreadOpaque.handle == NULL)
-+ {
-+ CLog::Log(LOGERROR, "%s - fatal error creating thread", __FUNCTION__);
-+ }
-+}
-+
-+void CThread::TermHandler()
-+{
-+ CloseHandle(m_ThreadOpaque.handle);
-+ m_ThreadOpaque.handle = NULL;
-+}
-+
-+void CThread::SetThreadInfo()
-+{
-+ const unsigned int MS_VC_EXCEPTION = 0x406d1388;
-+ struct THREADNAME_INFO
-+ {
-+ DWORD dwType; // must be 0x1000
-+ LPCSTR szName; // pointer to name (in same addr space)
-+ DWORD dwThreadID; // thread ID (-1 caller thread)
-+ DWORD dwFlags; // reserved for future use, most be zero
-+ } info;
-+
-+ info.dwType = 0x1000;
-+ info.szName = m_ThreadName.c_str();
-+ info.dwThreadID = m_ThreadId;
-+ info.dwFlags = 0;
-+
-+ try
-+ {
-+ RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
-+ }
-+ catch(...)
-+ {
-+ }
-+}
-+
-+ThreadIdentifier CThread::GetCurrentThreadId()
-+{
-+ return ::GetCurrentThreadId();
-+}
-+
-+bool CThread::IsCurrentThread(const ThreadIdentifier tid)
-+{
-+ return (::GetCurrentThreadId() == tid);
-+}
-+
-+int CThread::GetMinPriority(void)
-+{
-+ return(THREAD_PRIORITY_IDLE);
-+}
-+
-+int CThread::GetMaxPriority(void)
-+{
-+ return(THREAD_PRIORITY_HIGHEST);
-+}
-+
-+int CThread::GetNormalPriority(void)
-+{
-+ return(THREAD_PRIORITY_NORMAL);
-+}
-+
-+int CThread::GetSchedRRPriority(void)
-+{
-+ return GetNormalPriority();
-+}
-+
-+bool CThread::SetPriority(const int iPriority)
-+{
-+ bool bReturn = false;
-+
-+ CSingleLock lock(m_CriticalSection);
-+ if (m_ThreadOpaque.handle)
-+ {
-+ bReturn = SetThreadPriority(m_ThreadOpaque.handle, iPriority) == TRUE;
-+ }
-+
-+ return bReturn;
-+}
-+
-+int CThread::GetPriority()
-+{
-+ CSingleLock lock(m_CriticalSection);
-+
-+ int iReturn = THREAD_PRIORITY_NORMAL;
-+ if (m_ThreadOpaque.handle)
-+ {
-+ iReturn = GetThreadPriority(m_ThreadOpaque.handle);
-+ }
-+ return iReturn;
-+}
-+
-+bool CThread::WaitForThreadExit(unsigned int milliseconds)
-+{
-+ bool bReturn = true;
-+
-+ CSingleLock lock(m_CriticalSection);
-+ if (m_ThreadId && m_ThreadOpaque.handle != NULL)
-+ {
-+ // boost priority of thread we are waiting on to same as caller
-+ int callee = GetThreadPriority(m_ThreadOpaque.handle);
-+ int caller = GetThreadPriority(GetCurrentThread());
-+ if(caller > callee)
-+ SetThreadPriority(m_ThreadOpaque.handle, caller);
-+
-+ lock.Leave();
-+ bReturn = m_TermEvent.WaitMSec(milliseconds);
-+ lock.Enter();
-+
-+ // restore thread priority if thread hasn't exited
-+ if(caller > callee && m_ThreadOpaque.handle)
-+ SetThreadPriority(m_ThreadOpaque.handle, callee);
-+ }
-+ return bReturn;
-+}
-+
-+int64_t CThread::GetAbsoluteUsage()
-+{
-+ CSingleLock lock(m_CriticalSection);
-+
-+ if (!m_ThreadOpaque.handle)
-+ return 0;
-+
-+ uint64_t time = 0;
-+ FILETIME CreationTime, ExitTime, UserTime, KernelTime;
-+ if( GetThreadTimes(m_ThreadOpaque.handle, &CreationTime, &ExitTime, &KernelTime, &UserTime ) )
-+ {
-+ time = (((uint64_t)UserTime.dwHighDateTime) << 32) + ((uint64_t)UserTime.dwLowDateTime);
-+ time += (((uint64_t)KernelTime.dwHighDateTime) << 32) + ((uint64_t)KernelTime.dwLowDateTime);
-+ }
-+ return time;
-+}
-+
-+float CThread::GetRelativeUsage()
-+{
-+ unsigned int iTime = XbmcThreads::SystemClockMillis();
-+ iTime *= 10000; // convert into 100ns tics
-+
-+ // only update every 1 second
-+ if( iTime < m_iLastTime + 1000*10000 ) return m_fLastUsage;
-+
-+ int64_t iUsage = GetAbsoluteUsage();
-+
-+ if (m_iLastUsage > 0 && m_iLastTime > 0)
-+ m_fLastUsage = (float)( iUsage - m_iLastUsage ) / (float)( iTime - m_iLastTime );
-+
-+ m_iLastUsage = iUsage;
-+ m_iLastTime = iTime;
-+
-+ return m_fLastUsage;
-+}
-+
-+int64_t CThread::GetCurrentThreadUsage()
-+{
-+ HANDLE h = GetCurrentThread();
-+
-+ uint64_t time = 0;
-+ FILETIME CreationTime, ExitTime, UserTime, KernelTime;
-+ if( GetThreadTimes(h, &CreationTime, &ExitTime, &KernelTime, &UserTime ) )
-+ {
-+ time = (((uint64_t)UserTime.dwHighDateTime) << 32) + ((uint64_t)UserTime.dwLowDateTime);
-+ time += (((uint64_t)KernelTime.dwHighDateTime) << 32) + ((uint64_t)KernelTime.dwLowDateTime);
-+ }
-+ return time;
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/platform/win/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/platform/win/ThreadImpl.h 2012-05-14 14:15:12.212222039 +0200
-@@ -0,0 +1,40 @@
-+/*
-+* Copyright (C) 2005-2011 Team XBMC
-+* http://www.xbmc.org
-+*
-+* This Program 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, or (at your option)
-+* any later version.
-+*
-+* This Program 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 XBMC; see the file COPYING. If not, write to
-+* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+* http://www.gnu.org/copyleft/gpl.html
-+*
-+*/
-+
-+#pragma once
-+
-+#include
-+
-+
-+struct threadOpaque
-+{
-+ HANDLE handle;
-+};
-+
-+typedef DWORD ThreadIdentifier;
-+typedef threadOpaque ThreadOpaque;
-+typedef DWORD THREADFUNC;
-+
-+namespace XbmcThreads
-+{
-+ inline static void ThreadSleep(unsigned int millis) { Sleep(millis); }
-+}
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/Thread.cpp xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.cpp
---- xbmc-pvr-11.0.1/xbmc/threads/Thread.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.cpp 2012-05-14 14:15:12.214222079 +0200
-@@ -20,41 +20,27 @@
-
- #include "threads/SystemClock.h"
- #include "Thread.h"
--#ifndef _LINUX
--#include
--#include "utils/win32exception.h"
--#ifndef _MT
--#pragma message( "Please compile using multithreaded run-time libraries" )
--#endif
--typedef unsigned (WINAPI *PBEGINTHREADEX_THREADFUNC)(LPVOID lpThreadParameter);
--#else
--#include "PlatformInclude.h"
--#include "XHandle.h"
--#include
--typedef int (*PBEGINTHREADEX_THREADFUNC)(LPVOID lpThreadParameter);
--#endif
--
--#if defined(__GNUC__) && !defined(__clang__)
--#include
--using namespace __cxxabiv1;
--#endif
--
- #include "utils/log.h"
- #include "utils/TimeUtils.h"
- #include "threads/ThreadLocal.h"
-
-+#define __STDC_FORMAT_MACROS
-+#include
-+
- static XbmcThreads::ThreadLocal currentThread;
-
-+#include "threads/platform/ThreadImpl.cpp"
-+
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
-
--CThread::CThread(const char* ThreadName) : m_StopEvent(true,true)
-+CThread::CThread(const char* ThreadName)
-+: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
- {
- m_bStop = false;
-
- m_bAutoDelete = false;
-- m_ThreadHandle = NULL;
- m_ThreadId = 0;
- m_iLastTime = 0;
- m_iLastUsage = 0;
-@@ -66,12 +52,12 @@
- m_ThreadName = ThreadName;
- }
-
--CThread::CThread(IRunnable* pRunnable, const char* ThreadName) : m_StopEvent(true,true)
-+CThread::CThread(IRunnable* pRunnable, const char* ThreadName)
-+: m_StopEvent(true,true), m_TermEvent(true), m_StartEvent(true)
- {
- m_bStop = false;
-
- m_bAutoDelete = false;
-- m_ThreadHandle = NULL;
- m_ThreadId = 0;
- m_iLastTime = 0;
- m_iLastUsage = 0;
-@@ -85,171 +71,62 @@
-
- CThread::~CThread()
- {
-- if (m_ThreadHandle != NULL)
-- {
-- CloseHandle(m_ThreadHandle);
-- }
-- m_ThreadHandle = NULL;
--
-+ StopThread();
- }
-
--#ifndef _WIN32
--void CThread::term_handler (int signum)
-+bool CThread::IsRunning()
- {
-- CLog::Log(LOGERROR,"thread 0x%lx (%lu) got signal %d. calling OnException and terminating thread abnormally.", (long unsigned int)pthread_self(), (long unsigned int)pthread_self(), signum);
--
-- CThread* curThread = currentThread.get();
-- if (curThread)
-- {
-- curThread->m_bStop = TRUE;
-- curThread->m_StopEvent.Set();
--
-- curThread->OnException();
-- if( curThread->IsAutoDelete() )
-- delete curThread;
-- }
--
-- pthread_exit(NULL);
-+ return m_ThreadId ? true : false;
- }
-
--int CThread::staticThread(void* data)
--#else
--DWORD WINAPI CThread::staticThread(LPVOID* data)
--#endif
-+THREADFUNC CThread::staticThread(void* data)
- {
- CThread* pThread = (CThread*)(data);
-+ std::string name;
-+ ThreadIdentifier id;
-+ bool autodelete;
-+
- if (!pThread) {
- CLog::Log(LOGERROR,"%s, sanity failed. thread is NULL.",__FUNCTION__);
- return 1;
- }
-
-- if (pThread->m_ThreadName.empty())
-- pThread->m_ThreadName = pThread->GetTypeName();
-- pThread->SetDebugCallStackName(pThread->m_ThreadName.c_str());
-+ name = pThread->m_ThreadName;
-+ id = pThread->m_ThreadId;
-+ autodelete = pThread->m_bAutoDelete;
-
-- CLog::Log(LOGDEBUG,"Thread %s start, auto delete: %d", pThread->m_ThreadName.c_str(), pThread->IsAutoDelete());
-+ pThread->SetThreadInfo();
-+
-+ CLog::Log(LOGNOTICE,"Thread %s start, auto delete: %s", name.c_str(), (autodelete ? "true" : "false"));
-
- currentThread.set(pThread);
--#ifndef _LINUX
-- /* install win32 exception translator */
-- win32_exception::install_handler();
--#else
-- struct sigaction action;
-- action.sa_handler = term_handler;
-- sigemptyset (&action.sa_mask);
-- action.sa_flags = 0;
-- //sigaction (SIGABRT, &action, NULL);
-- //sigaction (SIGSEGV, &action, NULL);
--#endif
-+ pThread->m_StartEvent.Set();
-
-+ pThread->OnStartup();
-+ pThread->Process();
-+ pThread->OnExit();
-
-- try
-- {
-- pThread->OnStartup();
-- }
--#ifndef _LINUX
-- catch (const win32_exception &e)
-- {
-- e.writelog(__FUNCTION__);
-- if( pThread->IsAutoDelete() )
-- {
-- delete pThread;
-- _endthreadex(123);
-- return 0;
-- }
-- }
--#endif
-- catch(...)
-- {
-- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread startup, aborting. auto delete: %d", __FUNCTION__, pThread->m_ThreadName.c_str(), pThread->IsAutoDelete());
-- if( pThread->IsAutoDelete() )
-- {
-- delete pThread;
--#ifndef _LINUX
-- _endthreadex(123);
--#endif
-- return 0;
-- }
-- }
-+ // lock during termination
-+ CSingleLock lock(pThread->m_CriticalSection);
-
-- try
-- {
-- pThread->Process();
-- }
--#ifndef _LINUX
-- catch (const access_violation &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
-- catch (const win32_exception &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
--#endif
-- catch(...)
-- {
-- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread process, attemping cleanup in OnExit", __FUNCTION__, pThread->m_ThreadName.c_str());
-- }
-+ pThread->m_ThreadId = 0;
-+ pThread->m_TermEvent.Set();
-+ pThread->TermHandler();
-
-- try
-- {
-- pThread->OnExit();
-- }
--#ifndef _LINUX
-- catch (const access_violation &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
-- catch (const win32_exception &e)
-- {
-- e.writelog(__FUNCTION__);
-- }
--#endif
-- catch(...)
-- {
-- CLog::Log(LOGERROR, "%s - thread %s, Unhandled exception caught in thread exit", __FUNCTION__, pThread->m_ThreadName.c_str());
-- }
-+ lock.Leave();
-
-- if ( pThread->IsAutoDelete() )
-+ if (autodelete)
- {
-- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId());
-+ CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating (autodelete)", name.c_str(), (uint64_t)id);
- delete pThread;
- pThread = NULL;
- }
- else
-- CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", pThread->m_ThreadName.c_str(), (uint64_t)CThread::GetCurrentThreadId());
--
--// DXMERGE - this looks like it might have used to have been useful for something...
--// g_graphicsContext.DeleteThreadContext();
-+ CLog::Log(LOGDEBUG,"Thread %s %"PRIu64" terminating", name.c_str(), (uint64_t)id);
-
--#ifndef _LINUX
-- _endthreadex(123);
--#endif
- return 0;
- }
-
--void CThread::Create(bool bAutoDelete, unsigned stacksize)
--{
-- if (m_ThreadHandle != NULL)
-- {
-- throw 1; //ERROR should not b possible!!!
-- }
-- m_iLastTime = XbmcThreads::SystemClockMillis() * 10000;
-- m_iLastUsage = 0;
-- m_fLastUsage = 0.0f;
-- m_bAutoDelete = bAutoDelete;
-- m_bStop = false;
-- m_StopEvent.Reset();
--
-- m_ThreadHandle = (HANDLE)_beginthreadex(NULL, stacksize, (PBEGINTHREADEX_THREADFUNC)staticThread, (void*)this, 0, &m_ThreadId);
--
--#ifdef _LINUX
-- if (m_ThreadHandle && m_ThreadHandle->m_threadValid && m_bAutoDelete)
-- // FIXME: WinAPI can truncate 64bit pthread ids
-- pthread_detach(m_ThreadHandle->m_hThread);
--#endif
--}
--
- bool CThread::IsAutoDelete() const
- {
- return m_bAutoDelete;
-@@ -259,213 +136,17 @@
- {
- m_bStop = true;
- m_StopEvent.Set();
-- if (m_ThreadHandle && bWait)
-+ CSingleLock lock(m_CriticalSection);
-+ if (m_ThreadId && bWait)
- {
-- WaitForThreadExit(INFINITE);
-- CloseHandle(m_ThreadHandle);
-- m_ThreadHandle = NULL;
-+ lock.Leave();
-+ WaitForThreadExit(0xFFFFFFFF);
- }
- }
-
- ThreadIdentifier CThread::ThreadId() const
- {
--#ifdef _LINUX
-- if (m_ThreadHandle && m_ThreadHandle->m_threadValid)
-- return m_ThreadHandle->m_hThread;
-- else
-- return 0;
--#else
- return m_ThreadId;
--#endif
--}
--
--
--CThread::operator HANDLE()
--{
-- return m_ThreadHandle;
--}
--
--CThread::operator HANDLE() const
--{
-- return m_ThreadHandle;
--}
--
--bool CThread::SetPriority(const int iPriority)
--// Set thread priority
--// Return true for success
--{
-- bool rtn = false;
--
-- if (m_ThreadHandle)
-- {
-- rtn = SetThreadPriority( m_ThreadHandle, iPriority ) == TRUE;
-- }
--
-- return(rtn);
--}
--
--void CThread::SetPrioritySched_RR(void)
--{
--#ifdef __APPLE__
-- // Changing to SCHED_RR is safe under OSX, you don't need elevated privileges and the
-- // OSX scheduler will monitor SCHED_RR threads and drop to SCHED_OTHER if it detects
-- // the thread running away. OSX automatically does this with the CoreAudio audio
-- // device handler thread.
-- int32_t result;
-- thread_extended_policy_data_t theFixedPolicy;
--
-- // make thread fixed, set to 'true' for a non-fixed thread
-- theFixedPolicy.timeshare = false;
-- result = thread_policy_set(pthread_mach_thread_np(ThreadId()), THREAD_EXTENDED_POLICY,
-- (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT);
--
-- int policy;
-- struct sched_param param;
-- result = pthread_getschedparam(ThreadId(), &policy, ¶m );
-- // change from default SCHED_OTHER to SCHED_RR
-- policy = SCHED_RR;
-- result = pthread_setschedparam(ThreadId(), policy, ¶m );
--#endif
--}
--
--int CThread::GetMinPriority(void)
--{
--#if 0
--//#if defined(__APPLE__)
-- struct sched_param sched;
-- int rtn, policy;
--
-- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
-- int min = sched_get_priority_min(policy);
--
-- return(min);
--#else
-- return(THREAD_PRIORITY_IDLE);
--#endif
--}
--
--int CThread::GetMaxPriority(void)
--{
--#if 0
--//#if defined(__APPLE__)
-- struct sched_param sched;
-- int rtn, policy;
--
-- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
-- int max = sched_get_priority_max(policy);
--
-- return(max);
--#else
-- return(THREAD_PRIORITY_HIGHEST);
--#endif
--}
--
--int CThread::GetNormalPriority(void)
--{
--#if 0
--//#if defined(__APPLE__)
-- struct sched_param sched;
-- int rtn, policy;
--
-- rtn = pthread_getschedparam(ThreadId(), &policy, &sched);
-- int min = sched_get_priority_min(policy);
-- int max = sched_get_priority_max(policy);
--
-- return( min + ((max-min) / 2) );
--#else
-- return(THREAD_PRIORITY_NORMAL);
--#endif
--}
--
--
--void CThread::SetDebugCallStackName( const char *name )
--{
--#ifdef _WIN32
-- const unsigned int MS_VC_EXCEPTION = 0x406d1388;
-- struct THREADNAME_INFO
-- {
-- DWORD dwType; // must be 0x1000
-- LPCSTR szName; // pointer to name (in same addr space)
-- DWORD dwThreadID; // thread ID (-1 caller thread)
-- DWORD dwFlags; // reserved for future use, most be zero
-- } info;
--
-- info.dwType = 0x1000;
-- info.szName = name;
-- info.dwThreadID = m_ThreadId;
-- info.dwFlags = 0;
--
-- try
-- {
-- RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);
-- }
-- catch(...)
-- {
-- }
--#endif
--}
--
--// Get the thread name using the implementation dependant typeid() class
--// and attempt to clean it.
--std::string CThread::GetTypeName(void)
--{
-- std::string name = typeid(*this).name();
--
--#if defined(_MSC_VER)
-- // Visual Studio 2010 returns the name as "class CThread" etc
-- if (name.substr(0, 6) == "class ")
-- name = name.substr(6, name.length() - 6);
--#elif defined(__GNUC__) && !defined(__clang__)
-- // gcc provides __cxa_demangle to demangle the name
-- char* demangled = NULL;
-- int status;
--
-- demangled = __cxa_demangle(name.c_str(), NULL, 0, &status);
-- if (status == 0)
-- name = demangled;
-- else
-- CLog::Log(LOGDEBUG,"%s, __cxa_demangle(%s) failed with status %d", __FUNCTION__, name.c_str(), status);
--
-- if (demangled)
-- free(demangled);
--#endif
--
-- return name;
--}
--
--bool CThread::WaitForThreadExit(unsigned int milliseconds)
--// Waits for thread to exit, timeout in given number of msec.
--// Returns true when thread ended
--{
-- if (!m_ThreadHandle) return true;
--
--#ifndef _LINUX
-- // boost priority of thread we are waiting on to same as caller
-- int callee = GetThreadPriority(m_ThreadHandle);
-- int caller = GetThreadPriority(GetCurrentThread());
-- if(caller > callee)
-- SetThreadPriority(m_ThreadHandle, caller);
--
-- if (::WaitForSingleObject(m_ThreadHandle, milliseconds) != WAIT_TIMEOUT)
-- return true;
--
-- // restore thread priority if thread hasn't exited
-- if(caller > callee)
-- SetThreadPriority(m_ThreadHandle, callee);
--#else
-- if (!(m_ThreadHandle->m_threadValid) || pthread_join(m_ThreadHandle->m_hThread, NULL) == 0)
-- {
-- m_ThreadHandle->m_threadValid = false;
-- return true;
-- }
--#endif
--
-- return false;
--}
--
--HANDLE CThread::ThreadHandle()
--{
-- return m_ThreadHandle;
- }
-
- void CThread::Process()
-@@ -474,54 +155,14 @@
- m_pRunnable->Run();
- }
-
--float CThread::GetRelativeUsage()
--{
-- unsigned __int64 iTime = XbmcThreads::SystemClockMillis();
-- iTime *= 10000; // convert into 100ns tics
--
-- // only update every 1 second
-- if( iTime < m_iLastTime + 1000*10000 ) return m_fLastUsage;
--
-- FILETIME CreationTime, ExitTime, UserTime, KernelTime;
-- if( GetThreadTimes( m_ThreadHandle, &CreationTime, &ExitTime, &KernelTime, &UserTime ) )
-- {
-- unsigned __int64 iUsage = 0;
-- iUsage += (((unsigned __int64)UserTime.dwHighDateTime) << 32) + ((unsigned __int64)UserTime.dwLowDateTime);
-- iUsage += (((unsigned __int64)KernelTime.dwHighDateTime) << 32) + ((unsigned __int64)KernelTime.dwLowDateTime);
--
-- if(m_iLastUsage > 0 && m_iLastTime > 0)
-- m_fLastUsage = (float)( iUsage - m_iLastUsage ) / (float)( iTime - m_iLastTime );
--
-- m_iLastUsage = iUsage;
-- m_iLastTime = iTime;
--
-- return m_fLastUsage;
-- }
-- return 0.0f;
--}
--
- bool CThread::IsCurrentThread() const
- {
- return IsCurrentThread(ThreadId());
- }
-
--
--ThreadIdentifier CThread::GetCurrentThreadId()
-+CThread* CThread::GetCurrentThread()
- {
--#ifdef _LINUX
-- return pthread_self();
--#else
-- return ::GetCurrentThreadId();
--#endif
--}
--
--bool CThread::IsCurrentThread(const ThreadIdentifier tid)
--{
--#ifdef _LINUX
-- return pthread_equal(pthread_self(), tid);
--#else
-- return (::GetCurrentThreadId() == tid);
--#endif
-+ return currentThread.get();
- }
-
- void CThread::Sleep(unsigned int milliseconds)
-@@ -529,7 +170,7 @@
- if(milliseconds > 10 && IsCurrentThread())
- m_StopEvent.WaitMSec(milliseconds);
- else
-- ::Sleep(milliseconds);
-+ XbmcThreads::ThreadSleep(milliseconds);
- }
-
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/Thread.h xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.h
---- xbmc-pvr-11.0.1/xbmc/threads/Thread.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/Thread.h 2012-05-14 14:15:12.215222099 +0200
-@@ -23,19 +23,13 @@
- //
- //////////////////////////////////////////////////////////////////////
-
--#if !defined(AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_) && !defined(AFX_THREAD_H__67621B15_8724_4B5D_9343_7667075C89F2__INCLUDED_)
--#define AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_
--
--#if _MSC_VER > 1000
- #pragma once
--#endif // _MSC_VER > 1000
-
- #include
--#include "system.h" // for HANDLE
--#ifdef _LINUX
--#include "PlatformInclude.h"
--#endif
-+#include
- #include "Event.h"
-+#include "threads/ThreadImpl.h"
-+#include "threads/ThreadLocal.h"
-
- class IRunnable
- {
-@@ -44,37 +38,36 @@
- virtual ~IRunnable() {}
- };
-
--#ifdef CTHREAD
--#undef CTHREAD
--#endif
--
- // minimum as mandated by XTL
- #define THREAD_MINSTACKSIZE 0x10000
-
- class CThread
- {
- public:
-- CThread(const char* ThreadName = NULL);
-- CThread(IRunnable* pRunnable, const char* ThreadName = NULL);
-+ CThread(const char* ThreadName);
-+ CThread(IRunnable* pRunnable, const char* ThreadName);
- virtual ~CThread();
- void Create(bool bAutoDelete = false, unsigned stacksize = 0);
- bool WaitForThreadExit(unsigned int milliseconds);
- void Sleep(unsigned int milliseconds);
- bool SetPriority(const int iPriority);
-- void SetPrioritySched_RR(void);
-+ int GetPriority(void);
- int GetMinPriority(void);
- int GetMaxPriority(void);
- int GetNormalPriority(void);
-- HANDLE ThreadHandle();
-- operator HANDLE();
-- operator HANDLE() const;
-+ int GetSchedRRPriority(void);
-+ bool SetPrioritySched_RR(int iPriority);
- bool IsAutoDelete() const;
- virtual void StopThread(bool bWait = true);
- float GetRelativeUsage(); // returns the relative cpu usage of this thread since last call
-+ int64_t GetAbsoluteUsage();
- bool IsCurrentThread() const;
-+ bool IsRunning();
-
- static bool IsCurrentThread(const ThreadIdentifier tid);
- static ThreadIdentifier GetCurrentThreadId();
-+ static CThread* GetCurrentThread();
-+ static int64_t GetCurrentThreadUsage();
- protected:
- virtual void OnStartup(){};
- virtual void OnExit(){};
-@@ -82,7 +75,6 @@
- virtual void Process();
-
- volatile bool m_bStop;
-- HANDLE m_ThreadHandle;
-
- enum WaitResponse { WAIT_INTERRUPTED = -1, WAIT_SIGNALED = 0, WAIT_TIMEDOUT = 1 };
-
-@@ -108,36 +100,22 @@
- }
-
- private:
-- /*! \brief set the threadname for the debugger/callstack, implementation dependent.
-- */
-- void SetDebugCallStackName( const char *threadName );
-- std::string GetTypeName(void);
--
--private:
-+ static THREADFUNC staticThread(void *data);
- ThreadIdentifier ThreadId() const;
-+ void SetThreadInfo();
-+ void TermHandler();
-+
-+ ThreadIdentifier m_ThreadId;
-+ ThreadOpaque m_ThreadOpaque;
- bool m_bAutoDelete;
- CEvent m_StopEvent;
-- unsigned m_ThreadId; // This value is unreliable on platforms using pthreads
-- // Use m_ThreadHandle->m_hThread instead
-+ CEvent m_TermEvent;
-+ CEvent m_StartEvent;
-+ CCriticalSection m_CriticalSection;
- IRunnable* m_pRunnable;
--
-- unsigned __int64 m_iLastUsage;
-- unsigned __int64 m_iLastTime;
-+ uint64_t m_iLastUsage;
-+ uint64_t m_iLastTime;
- float m_fLastUsage;
-
- std::string m_ThreadName;
--
--#ifdef _LINUX
-- static void term_handler (int signum);
--#endif
--
--#ifndef _WIN32
-- static int staticThread(void* data);
--#else
-- static DWORD WINAPI staticThread(LPVOID* data);
--#endif
--
--private:
- };
--
--#endif // !defined(AFX_THREAD_H__ACFB7357_B961_4AC1_9FB2_779526219817__INCLUDED_)
-diff -Naur xbmc-pvr-11.0.1/xbmc/threads/ThreadImpl.h xbmc-pvr-11.0.1.patch/xbmc/threads/ThreadImpl.h
---- xbmc-pvr-11.0.1/xbmc/threads/ThreadImpl.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/threads/ThreadImpl.h 2012-05-14 14:15:12.215222099 +0200
-@@ -0,0 +1,25 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#pragma once
-+
-+#include "threads/platform/ThreadImpl.h"
-+
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/ActorProtocol.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/ActorProtocol.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.cpp 2012-05-14 14:15:12.216222119 +0200
-@@ -0,0 +1,254 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#include "ActorProtocol.h"
-+
-+using namespace Actor;
-+
-+void Message::Release()
-+{
-+ bool skip;
-+ origin->Lock();
-+ skip = isSync ? !isSyncFini : false;
-+ isSyncFini = true;
-+ origin->Unlock();
-+
-+ if (skip)
-+ return;
-+
-+ // free data buffer
-+ if (data != buffer)
-+ delete [] data;
-+
-+ // delete event in case of sync message
-+ if (event)
-+ delete event;
-+
-+ origin->ReturnMessage(this);
-+}
-+
-+bool Message::Reply(int sig, void *data /* = NULL*/, int size /* = 0 */)
-+{
-+ if (!isSync)
-+ {
-+ if (isOut)
-+ return origin->SendInMessage(sig, data, size);
-+ else
-+ return origin->SendOutMessage(sig, data, size);
-+ }
-+
-+ origin->Lock();
-+
-+ if (!isSyncTimeout)
-+ {
-+ Message *msg = origin->GetMessage();
-+ msg->signal = sig;
-+ msg->isOut = !isOut;
-+ replyMessage = msg;
-+ if (data)
-+ {
-+ if (size > MSG_INTERNAL_BUFFER_SIZE)
-+ msg->data = new uint8_t[size];
-+ else
-+ msg->data = msg->buffer;
-+ memcpy(msg->data, data, size);
-+ }
-+ }
-+
-+ origin->Unlock();
-+
-+ if (event)
-+ event->Set();
-+
-+ return true;
-+}
-+
-+Protocol::~Protocol()
-+{
-+ Message *msg;
-+ Purge();
-+ while (!freeMessageQueue.empty())
-+ {
-+ msg = freeMessageQueue.front();
-+ freeMessageQueue.pop();
-+ delete msg;
-+ }
-+}
-+
-+Message *Protocol::GetMessage()
-+{
-+ Message *msg;
-+
-+ CSingleLock lock(criticalSection);
-+
-+ if (!freeMessageQueue.empty())
-+ {
-+ msg = freeMessageQueue.front();
-+ freeMessageQueue.pop();
-+ }
-+ else
-+ msg = new Message();
-+
-+ msg->isSync = false;
-+ msg->isSyncFini = false;
-+ msg->isSyncTimeout = false;
-+ msg->event = NULL;
-+ msg->data = NULL;
-+ msg->payloadSize = 0;
-+ msg->replyMessage = NULL;
-+ msg->origin = this;
-+
-+ return msg;
-+}
-+
-+void Protocol::ReturnMessage(Message *msg)
-+{
-+ CSingleLock lock(criticalSection);
-+
-+ freeMessageQueue.push(msg);
-+}
-+
-+bool Protocol::SendOutMessage(int signal, void *data /* = NULL */, int size /* = 0 */, Message *outMsg /* = NULL */)
-+{
-+ Message *msg;
-+ if (outMsg)
-+ msg = outMsg;
-+ else
-+ msg = GetMessage();
-+
-+ msg->signal = signal;
-+ msg->isOut = true;
-+
-+ if (data)
-+ {
-+ if (size > MSG_INTERNAL_BUFFER_SIZE)
-+ msg->data = new uint8_t[size];
-+ else
-+ msg->data = msg->buffer;
-+ memcpy(msg->data, data, size);
-+ }
-+
-+ { CSingleLock lock(criticalSection);
-+ outMessages.push(msg);
-+ }
-+ containerOutEvent->Set();
-+
-+ return true;
-+}
-+
-+bool Protocol::SendInMessage(int signal, void *data /* = NULL */, int size /* = 0 */, Message *outMsg /* = NULL */)
-+{
-+ Message *msg;
-+ if (outMsg)
-+ msg = outMsg;
-+ else
-+ msg = GetMessage();
-+
-+ msg->signal = signal;
-+ msg->isOut = false;
-+
-+ if (data)
-+ {
-+ if (size > MSG_INTERNAL_BUFFER_SIZE)
-+ msg->data = new uint8_t[size];
-+ else
-+ msg->data = msg->buffer;
-+ memcpy(msg->data, data, size);
-+ }
-+
-+ { CSingleLock lock(criticalSection);
-+ inMessages.push(msg);
-+ }
-+ containerInEvent->Set();
-+
-+ return true;
-+}
-+
-+
-+bool Protocol::SendOutMessageSync(int signal, Message **retMsg, int timeout, void *data /* = NULL */, int size /* = 0 */)
-+{
-+ Message *msg = GetMessage();
-+ msg->isOut = true;
-+ msg->isSync = true;
-+ msg->event = new CEvent;
-+ msg->event->Reset();
-+ SendOutMessage(signal, data, size, msg);
-+
-+ if (!msg->event->WaitMSec(timeout))
-+ {
-+ msg->origin->Lock();
-+ if (msg->replyMessage)
-+ *retMsg = msg->replyMessage;
-+ else
-+ {
-+ *retMsg = NULL;
-+ msg->isSyncTimeout = true;
-+ }
-+ msg->origin->Unlock();
-+ }
-+ else
-+ *retMsg = msg->replyMessage;
-+
-+ msg->Release();
-+
-+ if (*retMsg)
-+ return true;
-+ else
-+ return false;
-+}
-+
-+bool Protocol::ReceiveOutMessage(Message **msg)
-+{
-+ CSingleLock lock(criticalSection);
-+
-+ if (outMessages.empty() || outDefered)
-+ return false;
-+
-+ *msg = outMessages.front();
-+ outMessages.pop();
-+
-+ return true;
-+}
-+
-+bool Protocol::ReceiveInMessage(Message **msg)
-+{
-+ CSingleLock lock(criticalSection);
-+
-+ if (inMessages.empty() || inDefered)
-+ return false;
-+
-+ *msg = inMessages.front();
-+ inMessages.pop();
-+
-+ return true;
-+}
-+
-+
-+void Protocol::Purge()
-+{
-+ Message *msg;
-+
-+ while (ReceiveInMessage(&msg))
-+ msg->Release();
-+
-+ while (ReceiveOutMessage(&msg))
-+ msg->Release();
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/ActorProtocol.h xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.h
---- xbmc-pvr-11.0.1/xbmc/utils/ActorProtocol.h 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/ActorProtocol.h 2012-05-14 14:15:12.217222140 +0200
-@@ -0,0 +1,89 @@
-+
-+#pragma once
-+
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#include "threads/Thread.h"
-+#include "utils/log.h"
-+#include
-+#include "memory.h"
-+
-+#define MSG_INTERNAL_BUFFER_SIZE 32
-+
-+namespace Actor
-+{
-+
-+class Protocol;
-+
-+class Message
-+{
-+ friend class Protocol;
-+public:
-+ int signal;
-+ bool isSync;
-+ bool isSyncFini;
-+ bool isOut;
-+ bool isSyncTimeout;
-+ int payloadSize;
-+ uint8_t buffer[MSG_INTERNAL_BUFFER_SIZE];
-+ uint8_t *data;
-+ Message *replyMessage;
-+ Protocol *origin;
-+ CEvent *event;
-+
-+ void Release();
-+ bool Reply(int sig, void *data = NULL, int size = 0);
-+
-+private:
-+ Message() {isSync = false; data = NULL; event = NULL; replyMessage = NULL;};
-+};
-+
-+class Protocol
-+{
-+public:
-+ Protocol(std::string name, CEvent* inEvent, CEvent *outEvent)
-+ : inDefered(false), outDefered(false), portName(name) {containerInEvent = inEvent; containerOutEvent = outEvent;};
-+ virtual ~Protocol();
-+ Message *GetMessage();
-+ void ReturnMessage(Message *msg);
-+ bool SendOutMessage(int signal, void *data = NULL, int size = 0, Message *outMsg = NULL);
-+ bool SendInMessage(int signal, void *data = NULL, int size = 0, Message *outMsg = NULL);
-+ bool SendOutMessageSync(int signal, Message **retMsg, int timeout, void *data = NULL, int size = 0);
-+ bool ReceiveOutMessage(Message **msg);
-+ bool ReceiveInMessage(Message **msg);
-+ void Purge();
-+ void DeferIn(bool value) {inDefered = value;};
-+ void DeferOut(bool value) {outDefered = value;};
-+ void Lock() {criticalSection.lock();};
-+ void Unlock() {criticalSection.unlock();};
-+ std::string portName;
-+
-+protected:
-+ CEvent *containerInEvent, *containerOutEvent;
-+ CCriticalSection criticalSection;
-+ std::queue outMessages;
-+ std::queue inMessages;
-+ std::queue freeMessageQueue;
-+ bool inDefered, outDefered;
-+};
-+
-+}
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/AlarmClock.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/AlarmClock.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/AlarmClock.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/AlarmClock.cpp 2012-05-14 14:15:12.217222140 +0200
-@@ -28,7 +28,7 @@
-
- using namespace std;
-
--CAlarmClock::CAlarmClock() : m_bIsRunning(false)
-+CAlarmClock::CAlarmClock() : CThread("CAlarmClock"), m_bIsRunning(false)
- {
- }
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/AsyncFileCopy.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/AsyncFileCopy.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/AsyncFileCopy.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/AsyncFileCopy.cpp 2012-05-14 14:15:12.218222160 +0200
-@@ -26,7 +26,7 @@
- #include "log.h"
- #include "utils/TimeUtils.h"
-
--CAsyncFileCopy::CAsyncFileCopy()
-+CAsyncFileCopy::CAsyncFileCopy() : CThread("CAsyncFileCopy")
- {
- m_cancelled = false;
- m_succeeded = false;
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.cpp 2012-05-14 14:15:12.218222160 +0200
-@@ -32,7 +32,7 @@
-
- WORD CDownloadQueue::m_wNextQueueId = 0;
-
--CDownloadQueue::CDownloadQueue(void) : CThread()
-+CDownloadQueue::CDownloadQueue(void) : CThread("CDownloadQueue")
- {
- m_bStop = false;
- m_wQueueId = m_wNextQueueId++;
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.h xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.h
---- xbmc-pvr-11.0.1/xbmc/utils/DownloadQueue.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueue.h 2012-05-14 14:15:12.219222180 +0200
-@@ -26,6 +26,8 @@
- #include "threads/CriticalSection.h"
- #include "StdString.h"
-
-+#include "system.h"
-+
- struct TICKET
- {
- TICKET(WORD aQueueId, DWORD aItemId)
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/DownloadQueueManager.h xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueueManager.h
---- xbmc-pvr-11.0.1/xbmc/utils/DownloadQueueManager.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/DownloadQueueManager.h 2012-05-14 14:15:12.220222200 +0200
-@@ -22,6 +22,7 @@
- */
-
- #include "DownloadQueue.h"
-+#include "system.h"
-
- #define MAX_DOWNLOAD_QUEUES 3
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/JobManager.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/JobManager.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/JobManager.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/JobManager.cpp 2012-05-14 14:15:12.220222200 +0200
-@@ -24,6 +24,9 @@
- #include "threads/SingleLock.h"
- #include "utils/log.h"
-
-+#include "system.h"
-+
-+
- using namespace std;
-
- bool CJob::ShouldCancel(unsigned int progress, unsigned int total) const
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/LCD.h xbmc-pvr-11.0.1.patch/xbmc/utils/LCD.h
---- xbmc-pvr-11.0.1/xbmc/utils/LCD.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/LCD.h 2012-05-14 14:15:12.221222220 +0200
-@@ -68,8 +68,9 @@
- void LoadSkin(const CStdString &xmlFile);
- void Reset();
- void Render(LCD_MODE mode);
-- ILCD() : m_disableOnPlay(DISABLE_ON_PLAY_NONE),
-- m_eCurrentCharset(CUSTOM_CHARSET_DEFAULT) {}
-+ ILCD() : CThread("ILCD"),
-+ m_disableOnPlay(DISABLE_ON_PLAY_NONE),
-+ m_eCurrentCharset(CUSTOM_CHARSET_DEFAULT) {}
- protected:
- virtual void Process() = 0;
- void StringToLCDCharSet(CStdString& strText);
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/Makefile xbmc-pvr-11.0.1.patch/xbmc/utils/Makefile
---- xbmc-pvr-11.0.1/xbmc/utils/Makefile 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/Makefile 2012-05-14 14:15:12.222222240 +0200
-@@ -59,6 +59,7 @@
- Weather.cpp \
- Win32Exception.cpp \
- XMLUtils.cpp \
-+ ActorProtocol.cpp \
-
- LIB=utils.a
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/RssReader.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/RssReader.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.cpp 2012-05-14 14:15:12.223222260 +0200
-@@ -44,7 +44,7 @@
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
-
--CRssReader::CRssReader() : CThread()
-+CRssReader::CRssReader() : CThread("CRssReader")
- {
- m_pObserver = NULL;
- m_spacesBetweenFeeds = 0;
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/RssReader.h xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.h
---- xbmc-pvr-11.0.1/xbmc/utils/RssReader.h 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/RssReader.h 2012-05-14 14:15:12.223222260 +0200
-@@ -39,6 +39,9 @@
-
- #include "tinyXML/tinyxml.h"
-
-+#include "system.h"
-+
-+
- #define RSS_COLOR_BODY 0
- #define RSS_COLOR_HEADLINE 1
- #define RSS_COLOR_CHANNEL 2
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/Splash.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/Splash.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/Splash.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/Splash.cpp 2012-05-14 14:15:12.224222280 +0200
-@@ -31,7 +31,7 @@
-
- using namespace XFILE;
-
--CSplash::CSplash(const CStdString& imageName)
-+CSplash::CSplash(const CStdString& imageName) : CThread("CSplash")
- {
- m_ImageName = imageName;
- fade = 0.5;
-@@ -139,5 +139,5 @@
-
- bool CSplash::IsRunning()
- {
-- return (m_ThreadHandle != NULL);
-+ return (IsRunning());
- }
-diff -Naur xbmc-pvr-11.0.1/xbmc/utils/TuxBoxUtil.cpp xbmc-pvr-11.0.1.patch/xbmc/utils/TuxBoxUtil.cpp
---- xbmc-pvr-11.0.1/xbmc/utils/TuxBoxUtil.cpp 2012-03-27 17:55:37.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/utils/TuxBoxUtil.cpp 2012-05-14 14:15:12.225222300 +0200
-@@ -48,7 +48,7 @@
- CTuxBoxUtil g_tuxbox;
- CTuxBoxService g_tuxboxService;
-
--CTuxBoxService::CTuxBoxService()
-+CTuxBoxService::CTuxBoxService() : CThread("CTuxBoxService")
- {
- }
- CTuxBoxService::~CTuxBoxService()
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/dialogs/GUIDialogVideoSettings.cpp xbmc-pvr-11.0.1.patch/xbmc/video/dialogs/GUIDialogVideoSettings.cpp
---- xbmc-pvr-11.0.1/xbmc/video/dialogs/GUIDialogVideoSettings.cpp 2012-05-14 14:14:51.709808795 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/dialogs/GUIDialogVideoSettings.cpp 2012-05-14 14:15:12.226222321 +0200
-@@ -107,12 +107,12 @@
- entries.push_back(make_pair(VS_INTERLACEMETHOD_INVERSE_TELECINE , 16314));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL , 16311));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL , 16310));
-- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_BOB , 16021));
-+ entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_BOB , 16326));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF, 16318));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF , 16317));
-- entries.push_back(make_pair(VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE , 16314));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BOB , 16320));
- entries.push_back(make_pair(VS_INTERLACEMETHOD_DXVA_BEST , 16321));
-+ entries.push_back(make_pair(VS_INTERLACEMETHOD_XVBA , 16327));
-
- /* remove unsupported methods */
- for(vector >::iterator it = entries.begin(); it != entries.end();)
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.cpp xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.cpp
---- xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.cpp 2012-05-14 14:15:12.227222342 +0200
-@@ -116,7 +116,7 @@
- m_state = FIND_MOVIE;
- m_strMovie = strMovie;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (m_state != DO_NOTHING)
-@@ -160,7 +160,7 @@
- { // threaded version
- m_state = GET_DETAILS;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (!m_found)
-@@ -195,7 +195,7 @@
- { // threaded version
- m_state = GET_EPISODE_DETAILS;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (!m_found)
-@@ -230,7 +230,7 @@
- { // threaded version
- m_state = GET_EPISODE_LIST;
- m_found = 0;
-- if (ThreadHandle())
-+ if (IsRunning())
- StopThread();
- Create();
- while (!m_found)
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.h xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.h
---- xbmc-pvr-11.0.1/xbmc/video/VideoInfoDownloader.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoDownloader.h 2012-05-14 14:15:12.228222362 +0200
-@@ -42,7 +42,7 @@
- class CVideoInfoDownloader : public CThread
- {
- public:
-- CVideoInfoDownloader(const ADDON::ScraperPtr &scraper) : m_info(scraper) {}
-+ CVideoInfoDownloader(const ADDON::ScraperPtr &scraper) : CThread("CVideoInfoDownloader"), m_info(scraper) {}
- virtual ~CVideoInfoDownloader() {}
-
- // threaded lookup functions
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoInfoScanner.cpp xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoScanner.cpp
---- xbmc-pvr-11.0.1/xbmc/video/VideoInfoScanner.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoInfoScanner.cpp 2012-05-14 14:15:12.229222382 +0200
-@@ -54,7 +54,7 @@
- namespace VIDEO
- {
-
-- CVideoInfoScanner::CVideoInfoScanner()
-+ CVideoInfoScanner::CVideoInfoScanner() : CThread("CVideoInfoScanner")
- {
- m_bRunning = false;
- m_pObserver = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.cpp xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.cpp
---- xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.cpp 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.cpp 2012-05-14 14:15:12.231222422 +0200
-@@ -31,6 +31,7 @@
- #include
- #include
- #include "windowing/WindowingFactory.h"
-+ #include "settings/AdvancedSettings.h"
- #define NVSETTINGSCMD "nvidia-settings -nt -q RefreshRate3"
- #elif defined(__APPLE__) && !defined(__arm__)
- #include
-@@ -107,7 +108,7 @@
-
- #endif
-
--CVideoReferenceClock::CVideoReferenceClock()
-+CVideoReferenceClock::CVideoReferenceClock() : CThread("CVideoReferenceClock")
- {
- m_SystemFrequency = CurrentHostFrequency();
- m_ClockSpeed = 1.0;
-@@ -118,7 +119,7 @@
-
- #if defined(HAS_GLX) && defined(HAS_XRANDR)
- m_Dpy = NULL;
-- m_UseNvSettings = true;
-+ m_UseNvSettings = false;
- #endif
- }
-
-@@ -270,12 +271,21 @@
- return false;
- }
-
-+ m_bIsATI = false;
-+ m_bPolling = false;
-+
- CStdString Vendor = g_Windowing.GetRenderVendor();
- Vendor.ToLower();
- if (Vendor.compare(0, 3, "ati") == 0)
- {
- CLog::Log(LOGDEBUG, "CVideoReferenceClock: GL_VENDOR: %s, using ati workaround", Vendor.c_str());
- m_bIsATI = true;
-+ m_bPolling = true;
-+ }
-+ if (g_advancedSettings.m_vblankPolling)
-+ {
-+ m_bPolling = true;
-+ CLog::Log(LOGDEBUG, "CVideoReferenceClock: use polling");
- }
-
- m_vInfo = glXChooseVisual(m_Dpy, DefaultScreen(m_Dpy), singleBufferAttributes);
-@@ -285,7 +295,7 @@
- return false;
- }
-
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- {
- Swa.border_pixel = 0;
- Swa.event_mask = StructureNotifyMask;
-@@ -313,7 +323,7 @@
- return false;
- }
-
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
- else
- ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context);
-@@ -324,7 +334,7 @@
- return false;
- }
-
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- {
- m_glXWaitVideoSyncSGI = (int (*)(int, int, unsigned int*))glXGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI");
- if (!m_glXWaitVideoSyncSGI)
-@@ -369,6 +379,9 @@
- UpdateRefreshrate(true); //forced refreshrate update
- m_MissedVblanks = 0;
-
-+ if (m_bPolling)
-+ SetPriority(1);
-+
- return true;
- }
-
-@@ -567,7 +580,7 @@
- while(!m_bStop)
- {
- //wait for the next vblank
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- {
- ReturnV = m_glXWaitVideoSyncSGI(2, (VblankCount + 1) % 2, &VblankCount);
- m_glXGetVideoSyncSGI(&VblankCount); //the vblank count returned by glXWaitVideoSyncSGI is not always correct
-@@ -591,7 +604,7 @@
- sleepTime = std::max(int(300000LL/m_RefreshRate), sleepTime);
-
- unsigned int iterations = 0;
-- while (VblankCount == PrevVblankCount && !m_bStop)
-+ while (VblankCount == PrevVblankCount && iterations < 500 && !m_bStop)
- {
- usleep(sleepTime);
- m_glXGetVideoSyncSGI(&VblankCount);
-@@ -652,7 +665,7 @@
- }
-
- CLog::Log(LOGDEBUG, "CVideoReferenceClock: Attaching glX context");
-- if (!m_bIsATI)
-+ if (!m_bPolling)
- ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context);
- else
- ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context);
-@@ -1275,6 +1288,9 @@
-
- if (m_UseVblank) //when true the vblank is used as clock source
- {
-+ if (Target < m_CurrTime)
-+ Target = m_CurrTime + 0.5/m_RefreshRate;
-+
- while (m_CurrTime < Target)
- {
- //calculate how long to sleep before we should have gotten a signal that a vblank happened
-diff -Naur xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.h xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.h
---- xbmc-pvr-11.0.1/xbmc/video/VideoReferenceClock.h 2012-03-27 17:55:34.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/video/VideoReferenceClock.h 2012-05-14 14:15:12.232222442 +0200
-@@ -125,6 +125,7 @@
-
- bool m_UseNvSettings;
- bool m_bIsATI;
-+ bool m_bPolling;
-
- #elif defined(_WIN32) && defined(HAS_DX)
- bool SetupD3D();
-diff -Naur xbmc-pvr-11.0.1/xbmc/win32/PlatformDefs.h xbmc-pvr-11.0.1.patch/xbmc/win32/PlatformDefs.h
---- xbmc-pvr-11.0.1/xbmc/win32/PlatformDefs.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/win32/PlatformDefs.h 2012-05-14 14:15:12.232222442 +0200
-@@ -33,7 +33,6 @@
- typedef __int64 fpos64_t;
- typedef __int64 __off64_t;
- typedef long __off_t;
--typedef unsigned long ThreadIdentifier;
-
- #define ssize_t int
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/win32/WindowHelper.cpp xbmc-pvr-11.0.1.patch/xbmc/win32/WindowHelper.cpp
---- xbmc-pvr-11.0.1/xbmc/win32/WindowHelper.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/win32/WindowHelper.cpp 2012-05-14 14:15:12.233222462 +0200
-@@ -28,7 +28,7 @@
-
- CWHelper g_windowHelper;
-
--CWHelper::CWHelper(void)
-+CWHelper::CWHelper(void) : CThread("CWHelper")
- {
- m_hwnd = NULL;
- m_hProcess = NULL;
-diff -Naur xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.cpp xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.cpp
---- xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.cpp 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.cpp 2012-05-14 14:15:12.234222482 +0200
-@@ -35,6 +35,8 @@
- #include
- #include "cores/VideoRenderers/RenderManager.h"
- #include "utils/TimeUtils.h"
-+#include "settings/AdvancedSettings.h"
-+#include "settings/GUISettings.h"
-
- #if defined(HAS_XRANDR)
- #include
-@@ -52,6 +54,7 @@
- m_wmWindow = 0;
- m_bWasFullScreenBeforeMinimize = false;
- m_dpyLostTime = 0;
-+ m_internalModeSwitch = false;
-
- XSetErrorHandler(XErrorHandler);
- }
-@@ -178,6 +181,45 @@
- return false;
- }
-
-+void CWinSystemX11::RefreshWindow()
-+{
-+ // save current mode if this is not an internal request
-+ if (!m_internalModeSwitch)
-+ {
-+ CLog::Log(LOGNOTICE, "CWinSystemX11::RefreshWindow - external or initial xrandr event");
-+ m_xrandrOut = g_xrandr.GetCurrentOutput();
-+ m_xrandrMode = g_xrandr.GetCurrentMode(m_xrandrOut.name);
-+ }
-+ m_internalModeSwitch = false;
-+
-+ g_xrandr.Query(true);
-+ XOutput out = g_xrandr.GetCurrentOutput();
-+ XMode mode = g_xrandr.GetCurrentMode(out.name);
-+
-+ RESOLUTION_INFO res;
-+ unsigned int i;
-+ bool found(false);
-+ for (i = RES_DESKTOP; i < g_settings.m_ResInfo.size(); ++i)
-+ {
-+ if (g_settings.m_ResInfo[i].strId == mode.id)
-+ {
-+ found = true;
-+ break;
-+ }
-+ }
-+
-+ if (!found)
-+ {
-+ CLog::Log(LOGERROR, "CWinSystemX11::RefreshWindow - could not find resolution");
-+ return;
-+ }
-+
-+ g_graphicsContext.SetVideoResolution((RESOLUTION)i, true);
-+ g_guiSettings.SetInt("window.width", mode.w);
-+ g_guiSettings.SetInt("window.height", mode.h);
-+ g_settings.Save();
-+}
-+
- bool CWinSystemX11::SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays)
- {
- m_nWidth = res.iWidth;
-@@ -193,13 +235,32 @@
- mode.hz = res.fRefreshRate;
- mode.id = res.strId;
-
-- if(m_bFullScreen)
-+ XOutput currout = g_xrandr.GetCurrentOutput();
-+ XMode currmode = g_xrandr.GetCurrentMode(currout.name);
-+
-+ if (m_xrandrOut.name.empty())
-+ {
-+ m_xrandrOut = currout;
-+ m_xrandrMode = currmode;
-+ }
-+
-+ if(!m_bFullScreen)
- {
-+ // reset to mode we had before internal mode switch
-+ out = m_xrandrOut;
-+ mode = m_xrandrMode;
-+ }
-+
-+ // only call xrandr if mode changes
-+ if (currout.name != out.name || currmode.w != mode.w || currmode.h != mode.h ||
-+ currmode.hz != mode.hz || currmode.id != mode.id)
-+ {
-+ CLog::Log(LOGNOTICE, "CWinSystemX11::SetFullScreen - calling xrandr");
- OnLostDevice();
-+ m_internalModeSwitch = true;
- g_xrandr.SetMode(out, mode);
- }
-- else
-- g_xrandr.RestoreState();
-+
- #endif
-
- int options = SDL_OPENGL;
-@@ -493,6 +554,7 @@
- if (bGotEvent || bTimeout)
- {
- CLog::Log(LOGDEBUG, "%s - notify display reset event", __FUNCTION__);
-+ RefreshWindow();
-
- CSingleLock lock(m_resourceSection);
-
-diff -Naur xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.h xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.h
---- xbmc-pvr-11.0.1/xbmc/windowing/X11/WinSystemX11.h 2012-03-27 17:55:38.000000000 +0200
-+++ xbmc-pvr-11.0.1.patch/xbmc/windowing/X11/WinSystemX11.h 2012-05-14 14:15:12.234222482 +0200
-@@ -27,6 +27,7 @@
- #include "utils/Stopwatch.h"
- #include
- #include "threads/CriticalSection.h"
-+#include "XRandR.h"
-
- class IDispResource;
-
-@@ -60,6 +61,9 @@
- // Local to WinSystemX11 only
- Display* GetDisplay() { return m_dpy; }
- GLXWindow GetWindow() { return m_glWindow; }
-+ GLXContext GetGlxContext() { return m_glContext; }
-+ Window GetWmWindow() { return m_wmWindow; }
-+ void RefreshWindow();
-
- protected:
- bool RefreshGlxContext();
-@@ -76,6 +80,9 @@
- CCriticalSection m_resourceSection;
- std::vector m_resources;
- uint64_t m_dpyLostTime;
-+ XOutput m_xrandrOut;
-+ XMode m_xrandrMode;
-+ bool m_internalModeSwitch;
-
- private:
- bool IsSuitableVisual(XVisualInfo *vInfo);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.02-xvba_support-gcc-4.7.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.02-xvba_support-gcc-4.7.patch
deleted file mode 100644
index 078997f175..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.02-xvba_support-gcc-4.7.patch
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -Naur xbmc-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h xbmc-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h
---- xbmc-11.0.1/xbmc/threads/platform/pthreads/ThreadImpl.h 2012-03-23 07:22:04.215885089 +0100
-+++ xbmc-11.0.1.patch/xbmc/threads/platform/pthreads/ThreadImpl.h 2012-03-23 07:24:07.875383186 +0100
-@@ -22,6 +22,7 @@
- #pragma once
-
- #include
-+#include
-
- struct threadOpaque
- {
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.03-fix_configure_in_VDPAU_detect.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.03-fix_configure_in_VDPAU_detect.patch
deleted file mode 100644
index f1c90b0544..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.03-fix_configure_in_VDPAU_detect.patch
+++ /dev/null
@@ -1,15 +0,0 @@
---- xbmc-pvr-11.0.2/configure.in.orig 2012-08-29 01:02:48.633007939 +0200
-+++ xbmc-pvr-11.0.2/configure.in 2012-08-29 01:03:40.593006545 +0200
-@@ -1287,11 +1287,7 @@
- AC_DEFINE([USE_EXTERNAL_FFMPEG], [1], [Whether to use external FFmpeg libraries.])
-
- # Disable vdpau support if external libavcodec doesn't have it
-- AC_RUN_IFELSE(
-- AC_LANG_PROGRAM([[#include ]],
-- [[avcodec_register_all();
-- AVCodec *codec = avcodec_find_decoder_by_name("vc1_vdpau");
-- return (codec) ? 0 : 1;]]),,
-+ AC_CHECK_LIB([avcodec], [ff_vdpau_vc1_decode_picture],,
- [if test "x$use_vdpau" = "xyes"; then
- AC_MSG_ERROR($ffmpeg_vdpau_not_supported)
- else
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.11-disable_interop.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.11-disable_interop.patch
deleted file mode 100644
index 18b28b23f7..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.11-disable_interop.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur xbmc-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp xbmc-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp
---- xbmc-11.0.1/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-06-30 19:13:51.558262433 +0200
-+++ xbmc-11.0.1.patch/xbmc/settings/GUIWindowSettingsCategory.cpp 2012-06-30 19:59:14.545818328 +0200
-@@ -553,7 +553,7 @@
- {
- bool hasInterop = false;
- #ifdef GL_NV_vdpau_interop
-- hasInterop = true;
-+ hasInterop = false;
- #endif
- CGUIControl *pControl = (CGUIControl *)GetControl(pSettingControl->GetID());
- if (pControl && hasInterop && glewIsSupported("GL_NV_vdpau_interop"))
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch
deleted file mode 100644
index 5f4ae3111c..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.12-linuxrenderer_delete_texture_targets_on_reconfigure.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 9687cc6b6f90fb40e39060eff9e4d8283254b770 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Fri, 13 Jul 2012 18:57:37 +0200
-Subject: [PATCH] linuxrenderer: delete texture targets on reconfigure
-
----
- xbmc/cores/VideoRenderers/LinuxRendererGL.cpp | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-index 7c46cfd..85fc50c 100644
---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-@@ -261,6 +261,12 @@ bool CLinuxRendererGL::ValidateRenderTarget()
- else
- CLog::Log(LOGNOTICE,"Using GL_TEXTURE_2D");
-
-+ // function pointer for texture might change in
-+ // call to LoadShaders
-+ glFinish();
-+ for (int i = 0 ; i < m_NumYV12Buffers ; i++)
-+ (this->*m_textureDelete)(i);
-+
- // create the yuv textures
- LoadShaders();
-
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.21-backport_vdpau_and_xvba_patches-b38863d.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.21-backport_vdpau_and_xvba_patches-b38863d.patch
deleted file mode 100644
index eca975c029..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.21-backport_vdpau_and_xvba_patches-b38863d.patch
+++ /dev/null
@@ -1,1420 +0,0 @@
-From 634226f3c604c38d6dd245800f05673583ba2dca Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Thu, 30 Aug 2012 12:38:39 +0200
-Subject: [PATCH 01/10] backport vdpau changes
-
----
- .../dvdplayer/DVDCodecs/Video/DVDVideoCodec.h | 4 +-
- xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 59 +++-----------------
- xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h | 10 ----
- xbmc/settings/GUISettings.cpp | 2 +-
- xbmc/settings/GUIWindowSettingsCategory.cpp | 4 +-
- 5 files changed, 13 insertions(+), 66 deletions(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
-index 3416506..01a8c78 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
-@@ -132,8 +132,7 @@ struct DVDVideoUserData
- #define DVP_FLAG_NOSKIP 0x00000010 // indicate this picture should never be dropped
- #define DVP_FLAG_DROPPED 0x00000020 // indicate that this picture has been dropped in decoder stage, will have no data
- #define DVP_FLAG_DROPDEINT 0x00000040 // indicate that this picture was requested to have been dropped in deint stage
--
--#define DVP_FLAG_SKIP_PROC 0x00000100
-+#define DVP_FLAG_NO_POSTPROC 0x00000100
- #define DVP_FLAG_DRAIN 0x00000200
-
- // DVP_FLAG 0x00000100 - 0x00000f00 is in use by libmpeg2!
-@@ -155,7 +154,6 @@ struct DVDVideoUserData
- #define VC_FLUSHED 0x00000010 // the decoder lost it's state, we need to restart decoding again
- #define VC_DROPPED 0x00000020 // needed to identify if a picture was dropped
- #define VC_HURRY 0x00000040
--#define VC_SKIPPROC 0x00000080
-
- class CDVDVideoCodec
- {
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-index aed9d63..16edf55 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-@@ -95,10 +95,8 @@
- m_vdpauConfig.videoSurfaces = &m_videoSurfaces;
- m_vdpauConfig.videoSurfaceSec = &m_videoSurfaceSec;
-
-- m_picAge.b_age = m_picAge.ip_age[0] = m_picAge.ip_age[1] = 256*256*256*64;
- m_vdpauConfigured = false;
- m_DisplayState = VDPAU_OPEN;
-- m_speed = DVD_PLAYSPEED_NORMAL;
- }
-
- bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
-@@ -252,13 +250,6 @@ long CDecoder::ReleasePicReference()
-
- void CDecoder::SetWidthHeight(int width, int height)
- {
-- int vdpauMaxHeight = g_advancedSettings.m_videoVDPAUmaxHeight;
-- if (vdpauMaxHeight > 0 && height > vdpauMaxHeight)
-- {
-- width = MathUtils::round_int((double)width * vdpauMaxHeight / height);
-- height = vdpauMaxHeight;
-- }
--
- m_vdpauConfig.upscale = g_advancedSettings.m_videoVDPAUScaling;
-
- //pick the smallest dimensions, so we downscale with vdpau and upscale with opengl when appropriate
-@@ -282,7 +273,7 @@ void CDecoder::SetWidthHeight(int width, int height)
- m_vdpauConfig.outWidth = width;
- m_vdpauConfig.outHeight = height;
- }
-- CLog::Log(LOGDEBUG, "CVDPAU::SetWidthHeight Setting OutWidth: %i OutHeight: %i vdpauMaxHeight: %i", m_vdpauConfig.outWidth, m_vdpauConfig.outHeight, vdpauMaxHeight);
-+ CLog::Log(LOGDEBUG, "CVDPAU::SetWidthHeight Setting OutWidth: %i OutHeight: %i", m_vdpauConfig.outWidth, m_vdpauConfig.outHeight);
- }
-
- void CDecoder::OnLostDevice()
-@@ -710,7 +701,6 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
- CDecoder* vdp = (CDecoder*)ctx->GetHardware();
-- struct PictureAge* pA = &vdp->m_picAge;
-
- // while we are waiting to recover we can't do anything
- CSingleLock lock(vdp->m_DecoderSection);
-@@ -777,18 +767,6 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
-
- pic->linesize[0] = pic->linesize[1] = pic->linesize[2] = 0;
-
-- if(pic->reference)
-- {
-- pA->ip_age[0]= pA->ip_age[1]+1;
-- pA->ip_age[1]= 1;
-- pA->b_age++;
-- }
-- else
-- {
-- pA->ip_age[0]++;
-- pA->ip_age[1]++;
-- pA->b_age = 1;
-- }
- pic->type= FF_BUFFER_TYPE_USER;
-
- render->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE;
-@@ -937,11 +915,7 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame, bool bSoftDrain, bo
- m_bufferStats.IncDecoded();
- m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic));
-
-- m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_SKIP_PROC);
-- if (m_codecControl & DVP_FLAG_SKIP_PROC)
-- {
-- m_bufferStats.SetCmd(DVP_FLAG_SKIP_PROC);
-- }
-+ m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_NO_POSTPROC);
- }
-
- int retval = 0;
-@@ -1017,7 +991,7 @@ int CDecoder::Decode(AVCodecContext *avctx, AVFrame *pFrame, bool bSoftDrain, bo
- uint64_t diff = CurrentHostCounter() - startTime;
- if (retval & VC_PICTURE)
- {
-- m_bufferStats.SetParams(diff, m_speed);
-+ m_bufferStats.SetParams(diff, m_codecControl);
- }
- if (diff*1000/CurrentHostFrequency() > 50)
- CLog::Log(LOGDEBUG,"CVDPAU::Decode long wait: %d", (int)((diff*1000)/CurrentHostFrequency()));
-@@ -1079,11 +1053,6 @@ bool CDecoder::CanSkipDeint()
- return m_bufferStats.CanSkipDeint();
- }
-
--void CDecoder::SetSpeed(int speed)
--{
-- m_speed = speed;
--}
--
- void CDecoder::ReturnRenderPicture(CVdpauRenderPicture *renderPic)
- {
- m_vdpauOutput.m_dataPort.SendOutMessage(COutputDataProtocol::RETURNPIC, &renderPic, sizeof(renderPic));
-@@ -1150,7 +1119,6 @@ void CVdpauRenderPicture::ReturnUnused()
- if (vdpau)
- vdpau->ReturnRenderPicture(this);
- }
--
- //-----------------------------------------------------------------------------
- // Mixer
- //-----------------------------------------------------------------------------
-@@ -1847,7 +1815,7 @@ void CMixer::SetDeinterlacing()
- {
- if (method == VS_INTERLACEMETHOD_AUTO)
- {
-- VdpBool enabled[] = {1,1,0};
-+ VdpBool enabled[] = {1,0,0};
- if (g_advancedSettings.m_videoVDPAUtelecine)
- enabled[2] = 1;
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
-@@ -2127,10 +2095,10 @@ void CMixer::InitCycle()
- {
- CheckFeatures();
- uint64_t latency;
-- int speed;
-- m_config.stats->GetParams(latency, speed);
-+ int flags;
-+ m_config.stats->GetParams(latency, flags);
- latency = (latency*1000)/CurrentHostFrequency();
-- if (speed != DVD_PLAYSPEED_NORMAL)
-+ if (flags & DVP_FLAG_NO_POSTPROC)
- SetPostProcFeatures(false);
- else
- SetPostProcFeatures(true);
-@@ -2248,14 +2216,6 @@ void CMixer::ProcessPicture()
- if (m_processPicture.DVDPic.format == DVDVideoPicture::FMT_VDPAU_420)
- return;
-
-- int cmd = 0;
-- m_config.stats->GetCmd(cmd);
-- if (cmd & DVP_FLAG_SKIP_PROC)
-- {
-- m_processPicture.DVDPic.iFlags |= DVP_FLAG_DROPPED;
-- return;
-- }
--
- VdpStatus vdp_st;
-
- if (m_mixerstep == 1)
-@@ -3222,7 +3182,7 @@ bool COutput::GLInit()
- glVDPAUGetSurfaceivNV = NULL;
- #endif
-
-- m_config.usePixmaps = !g_guiSettings.GetBool("videoplayer.usevdpauinteroprgb");
-+ m_config.usePixmaps = !g_guiSettings.GetBool("videoplayer.usevdpauinterop");
-
- #ifdef GL_NV_vdpau_interop
- if (glewIsSupported("GL_NV_vdpau_interop"))
-@@ -3254,7 +3214,7 @@ bool COutput::GLInit()
- #endif
- {
- m_config.usePixmaps = true;
-- g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinterop",false);
- g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
- }
- if (!glXBindTexImageEXT)
-@@ -3538,5 +3498,4 @@ bool COutput::DestroyGlxContext()
- return true;
- }
-
--
- #endif
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
-index e08687c..17f1f6e 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
-@@ -508,12 +508,6 @@ class CDecoder
-
- public:
-
-- struct PictureAge
-- {
-- int b_age;
-- int ip_age[2];
-- };
--
- struct Desc
- {
- const char *name;
-@@ -532,7 +526,6 @@ class CDecoder
- virtual void Close();
- virtual long Release();
- virtual bool CanSkipDeint();
-- virtual void SetSpeed(int speed);
-
- virtual int Check(AVCodecContext* avctx);
- virtual const std::string Name() { return "vdpau"; }
-@@ -591,16 +584,13 @@ class CDecoder
- CVdpauConfig m_vdpauConfig;
- std::vector m_videoSurfaces;
- CCriticalSection m_videoSurfaceSec;
-- PictureAge m_picAge;
-
- COutput m_vdpauOutput;
- CVdpauBufferStats m_bufferStats;
- CEvent m_inMsgEvent;
- CVdpauRenderPicture *m_presentPicture;
-
-- int m_speed;
- int m_codecControl;
- };
-
- }
--
-diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp
-index 4e8aabb..2d79423 100644
---- a/xbmc/settings/GUISettings.cpp
-+++ b/xbmc/settings/GUISettings.cpp
-@@ -597,7 +597,7 @@ void CGUISettings::Initialize()
-
- #ifdef HAVE_LIBVDPAU
- AddBool(vp, "videoplayer.usevdpau", 13425, true);
-- AddBool(vp, "videoplayer.usevdpauinteroprgb", 13433, true);
-+ AddBool(vp, "videoplayer.usevdpauinterop", 13433, true);
- AddBool(vp, "videoplayer.usevdpauinteropyuv", 13434, true);
- #endif
- #ifdef HAVE_LIBVA
-diff --git a/xbmc/settings/GUIWindowSettingsCategory.cpp b/xbmc/settings/GUIWindowSettingsCategory.cpp
-index a69f130..40becc0 100644
---- a/xbmc/settings/GUIWindowSettingsCategory.cpp
-+++ b/xbmc/settings/GUIWindowSettingsCategory.cpp
-@@ -577,7 +577,7 @@ void CGUIWindowSettingsCategory::UpdateSettings()
- g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
- }
- }
-- else if (strSetting.Equals("videoplayer.usevdpauinteroprgb"))
-+ else if (strSetting.Equals("videoplayer.usevdpauinterop"))
- {
- bool hasInterop = false;
- #ifdef GL_NV_vdpau_interop
-@@ -591,7 +591,7 @@ void CGUIWindowSettingsCategory::UpdateSettings()
- else
- {
- pControl->SetEnabled(false);
-- g_guiSettings.SetBool("videoplayer.usevdpauinteroprgb",false);
-+ g_guiSettings.SetBool("videoplayer.usevdpauinterop",false);
- }
- }
- else
---
-1.7.10
-
-
-From d0c23ddfad95612c47bcf9ce430b00a414b42912 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Thu, 30 Aug 2012 14:10:35 +0200
-Subject: [PATCH 02/10] backport some player and renderer changes
-
----
- xbmc/cores/VideoRenderers/BaseRenderer.h | 3 +
- xbmc/cores/VideoRenderers/LinuxRendererGL.cpp | 31 +++----
- xbmc/cores/VideoRenderers/LinuxRendererGL.h | 2 +
- xbmc/cores/VideoRenderers/RenderManager.cpp | 90 ++++++++------------
- xbmc/cores/VideoRenderers/RenderManager.h | 14 +--
- .../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 12 +--
- .../DVDCodecs/Video/DVDVideoCodecFFmpeg.h | 6 +-
- xbmc/cores/dvdplayer/DVDPlayerVideo.cpp | 65 +++-----------
- 8 files changed, 71 insertions(+), 152 deletions(-)
-
-diff --git a/xbmc/cores/VideoRenderers/BaseRenderer.h b/xbmc/cores/VideoRenderers/BaseRenderer.h
-index af51852..0c2de2c 100644
---- a/xbmc/cores/VideoRenderers/BaseRenderer.h
-+++ b/xbmc/cores/VideoRenderers/BaseRenderer.h
-@@ -67,6 +67,9 @@ class CBaseRenderer
- virtual void Flush() {};
-
- virtual unsigned int GetProcessorSize() { return 0; }
-+ virtual unsigned int GetMaxProcessorSize() { return 0; }
-+ virtual void SetProcessorSize(int numBuffers) { }
-+ virtual void ReleaseBuffer(int idx) { }
-
- protected:
- void ChooseBestResolution(float fps);
-diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-index 186ef2c..b0ad6e4 100644
---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-@@ -77,7 +77,6 @@
- using namespace Shaders;
-
- static const GLubyte stipple_weave[] = {
-- 0xFF, 0xFF, 0xFF, 0xFF,
- 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0xFF, 0xFF,
- 0x00, 0x00, 0x00, 0x00,
-@@ -110,6 +109,7 @@
- 0xFF, 0xFF, 0xFF, 0xFF,
- 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0xFF, 0xFF,
-+ 0x00, 0x00, 0x00, 0x00,
- };
-
- CLinuxRendererGL::YUVBUFFER::YUVBUFFER()
-@@ -249,11 +249,6 @@ bool CLinuxRendererGL::ValidateRenderTarget()
-
- // function pointer for texture might change in
- // call to LoadShaders
-- for (int i = 0 ; i < m_NumYV12Buffers ; i++)
-- (this->*m_textureDelete)(i);
--
-- // function pointer for texture might change in
-- // call to LoadShaders
- glFinish();
- for (int i = 0 ; i < m_NumYV12Buffers ; i++)
- (this->*m_textureDelete)(i);
-@@ -633,8 +628,6 @@ void CLinuxRendererGL::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
- index = m_iYV12RenderBuffer;
- }
- }
-- else
-- m_iLastRenderBuffer = index;
-
- if (clear)
- {
-@@ -750,6 +743,8 @@ void CLinuxRendererGL::FlipPage(int source)
- {
- UnBindPbo(m_buffers[m_iYV12RenderBuffer]);
-
-+ m_iLastRenderBuffer = m_iYV12RenderBuffer;
-+
- if( source >= 0 && source < m_NumYV12Buffers )
- m_iYV12RenderBuffer = source;
- else
-@@ -1147,7 +1142,10 @@ void CLinuxRendererGL::Render(DWORD flags, int renderBuffer)
- m_currentField = FIELD_FULL;
-
- // call texture load function
-+ m_skipRender = false;
- (this->*m_textureUpload)(renderBuffer);
-+ if (m_skipRender)
-+ return;
-
- if (m_renderMethod & RENDER_GLSL)
- {
-@@ -2332,16 +2330,13 @@ void CLinuxRendererGL::UploadVDPAUTexture(int index)
- YUVFIELDS &fields = m_buffers[index].fields;
- YUVPLANE &plane = fields[0][0];
-
-- if (!vdpau)
-+ if (!vdpau || !vdpau->valid)
- {
-- fields[0][1].id = plane.id;
- m_eventTexturesDone[index]->Set();
-- CLog::Log(LOGWARNING,"--------- no vdpau texture, index: %d", index);
-+ m_skipRender = true;
- return;
- }
-
--// CLog::Log(LOGNOTICE,"-------- rendered output surf: %d", vdpau->sourceIdx);
--// CLog::Log(LOGNOTICE,"-------- pts: %f", vdpau->DVDPic.pts);
- fields[0][1].id = vdpau->texture[0];
-
- m_eventTexturesDone[index]->Set();
-@@ -2411,13 +2406,10 @@ void CLinuxRendererGL::UploadVDPAUTexture420(int index)
- YUVFIELDS &fields = m_buffers[index].fields;
- YUVPLANE &plane = fields[0][0];
-
-- if (!vdpau)
-+ if (!vdpau || !vdpau->valid)
- {
-- fields[1][0].id = plane.id;
-- fields[1][1].id = plane.id;
-- fields[2][0].id = plane.id;
-- fields[2][1].id = plane.id;
- m_eventTexturesDone[index]->Set();
-+ m_skipRender = true;
- return;
- }
-
-@@ -2479,7 +2471,6 @@ void CLinuxRendererGL::UploadVDPAUTexture420(int index)
- #endif
- }
-
--
- void CLinuxRendererGL::DeleteVAAPITexture(int index)
- {
- #ifdef HAVE_LIBVA
-@@ -2610,7 +2601,7 @@ void CLinuxRendererGL::UploadVAAPITexture(int index)
- || status == VA_STATUS_ERROR_INVALID_DISPLAY)
- {
- va.display->lost(true);
-- for(int i = 0; i < NUM_BUFFERS; i++)
-+ for(int i = 0; i < m_NumYV12Buffers; i++)
- {
- m_buffers[i].vaapi.display.reset();
- m_buffers[i].vaapi.surface.reset();
-diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.h b/xbmc/cores/VideoRenderers/LinuxRendererGL.h
-index 9dfe679..4a8da39 100644
---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.h
-+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.h
-@@ -145,6 +145,7 @@ class CLinuxRendererGL : public CBaseRenderer
- virtual void Flush();
- virtual void ReleaseBuffer(int idx);
- virtual void SetProcessorSize(int numBuffers) { m_NumYV12Buffers = numBuffers; }
-+ virtual unsigned int GetMaxProcessorSize() { return NUM_BUFFERS; }
- virtual unsigned int GetProcessorSize() { return m_NumYV12Buffers; }
-
- #ifdef HAVE_LIBVDPAU
-@@ -328,6 +329,7 @@ class CLinuxRendererGL : public CBaseRenderer
- bool m_nonLinStretch;
- bool m_nonLinStretchGui;
- float m_pixelRatio;
-+ bool m_skipRender;
- };
-
-
-diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp
-index c94c699..95372e0 100644
---- a/xbmc/cores/VideoRenderers/RenderManager.cpp
-+++ b/xbmc/cores/VideoRenderers/RenderManager.cpp
-@@ -235,6 +235,13 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
- return false;
- }
-
-+ // check if decoder supports buffering
-+ m_bCodecSupportsBuffering = false;
-+ if (format == DVDVideoPicture::FMT_VDPAU
-+ || format == DVDVideoPicture::FMT_VDPAU_420
-+ || format == DVDVideoPicture::FMT_XVBA)
-+ m_bCodecSupportsBuffering = true;
-+
- bool result = m_pRenderer->Configure(width, height, d_width, d_height, fps, flags, format);
- if(result)
- {
-@@ -249,7 +256,7 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
- m_bReconfigured = true;
- m_presentstep = PRESENT_IDLE;
- m_presentevent.Set();
--// ResetRenderBuffer();
-+ ResetRenderBuffer();
- }
-
- return result;
-@@ -294,8 +301,6 @@ void CXBMCRenderManager::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
- }
- }
-
--// CLog::Log(LOGNOTICE,"------ current: %d", m_iCurrentRenderBuffer);
--
- if (g_advancedSettings.m_videoDisableBackgroundDeinterlace)
- {
- CSharedLock lock(m_sharedSection);
-@@ -334,17 +339,10 @@ unsigned int CXBMCRenderManager::PreInit(CDVDClock *pClock)
-
- UpdateDisplayLatency();
-
-- m_swapCount = 1;
--// std::string Vendor = g_Windowing.GetRenderVendor();
--// std::transform(Vendor.begin(), Vendor.end(), Vendor.begin(), ::tolower);
--// if (Vendor.compare(0, 3, "ati") == 0)
--// {
--// m_swapCount = 2;
--// }
-- ResetRenderBuffer();
- m_bUseBuffering = false;
-- m_overlays.SetNumBuffers(m_iNumRenderBuffers);
-- m_pRenderer->SetProcessorSize(m_iNumRenderBuffers);
-+ m_bCodecSupportsBuffering = true;
-+ ResetRenderBuffer();
-+
- return m_pRenderer->PreInit();
- }
-
-@@ -680,8 +678,6 @@ void CXBMCRenderManager::Present()
- WaitPresentTime(m_presenttime);
-
- m_presentevent.Set();
--
-- m_rendertime = CurrentHostCounter();
- }
-
- /* simple present method */
-@@ -915,9 +911,9 @@ bool CXBMCRenderManager::HasFreeBuffer()
- return true;
- }
-
-- int outputPlusSwap = (m_iOutputRenderBuffer + m_swapCount) % m_iNumRenderBuffers;
-+ int outputPlus1 = (m_iOutputRenderBuffer + 1) % m_iNumRenderBuffers;
- if ((m_iOutputRenderBuffer == m_iDisplayedRenderBuffer && !m_bAllRenderBuffersDisplayed)
-- || outputPlusSwap == m_iCurrentRenderBuffer)
-+ || outputPlus1 == m_iCurrentRenderBuffer)
- return false;
- else
- return true;
-@@ -925,15 +921,23 @@ bool CXBMCRenderManager::HasFreeBuffer()
-
- void CXBMCRenderManager::ResetRenderBuffer()
- {
-- m_iNumRenderBuffers = 5;
-+ m_iNumRenderBuffers = m_pRenderer->GetMaxProcessorSize();
-+ m_iNumRenderBuffers = std::min(5, m_iNumRenderBuffers);
-+ m_iNumRenderBuffers = std::max(2, m_iNumRenderBuffers);
-+
-+ if (!m_bCodecSupportsBuffering)
-+ m_iNumRenderBuffers = 2;
-+
-+ CLog::Log(LOGNOTICE,"CXBMCRenderManager::ResetRenderBuffer - using %d render buffers", m_iNumRenderBuffers);
-+ m_overlays.SetNumBuffers(m_iNumRenderBuffers);
-+ m_pRenderer->SetProcessorSize(m_iNumRenderBuffers);
-+
- m_iCurrentRenderBuffer = 0;
-- m_iFlipRequestRenderBuffer = 0;
- m_iOutputRenderBuffer = 0;
- m_iDisplayedRenderBuffer = 0;
- m_bAllRenderBuffersDisplayed = true;
- m_sleeptime = 1.0;
- m_presentPts = DVD_NOPTS_VALUE;
--// m_bUseBuffering = true;
- m_speed = 0;
- }
-
-@@ -943,8 +947,8 @@ void CXBMCRenderManager::PrepareNextRender()
- if (idx < 0)
- {
- if (m_speed >= DVD_PLAYSPEED_NORMAL && g_graphicsContext.IsFullScreenVideo())
-- CLog::Log(LOGNOTICE,"----------- no buffer, out: %d, current: %d, display: %d",
-- m_iOutputRenderBuffer, m_iCurrentRenderBuffer, m_iDisplayedRenderBuffer);
-+ CLog::Log(LOGDEBUG,"%s no buffer, out: %d, current: %d, display: %d",
-+ __FUNCTION__, m_iOutputRenderBuffer, m_iCurrentRenderBuffer, m_iDisplayedRenderBuffer);
- return;
- }
-
-@@ -962,16 +966,6 @@ void CXBMCRenderManager::PrepareNextRender()
-
- m_sleeptime = presenttime - clocktime;
-
--// double interval;
--// if (g_VideoReferenceClock.GetRefreshRate(&interval) > 0)
--// {
--// if (m_swaptime > interval * 0.7)
--// {
--// presenttime += interval;
--// CLog::Log(LOGDEBUG,"------------ very long swaptime");
--// }
--// }
--
- if (g_graphicsContext.IsFullScreenVideo() || presenttime <= clocktime+0.01)
- {
- m_presentPts = m_renderBuffers[idx].pts;
-@@ -986,6 +980,10 @@ void CXBMCRenderManager::PrepareNextRender()
- void CXBMCRenderManager::EnableBuffering(bool enable)
- {
- CRetakeLock lock(m_sharedSection);
-+
-+ if (m_iNumRenderBuffers < 3)
-+ return;
-+
- m_bUseBuffering = enable;
- if (!m_bUseBuffering)
- m_iOutputRenderBuffer = m_iCurrentRenderBuffer;
-@@ -1005,28 +1003,11 @@ void CXBMCRenderManager::NotifyDisplayFlip()
- if (!m_pRenderer)
- return;
-
--// if (g_graphicsContext.IsFullScreenVideo())
--// {
--// uint64_t diff = CurrentHostCounter() - m_rendertime;
--// m_swaptime = ((double)(diff))/CurrentHostFrequency();
--// int waittime = (int)((diff*1000LL)/CurrentHostFrequency());
--// if (waittime > 15)
--// {
--// CLog::Log(LOGNOTICE,"------------------ wait swap buffers: %f, sleep: %f", m_swaptime, m_sleeptime);
--// }
--// }
-+ if (m_iNumRenderBuffers < 3)
-+ return;
-
- int last = m_iDisplayedRenderBuffer;
-- m_iDisplayedRenderBuffer = (m_iCurrentRenderBuffer + m_iNumRenderBuffers - m_swapCount) % m_iNumRenderBuffers;
-- m_iFlipRequestRenderBuffer = m_iCurrentRenderBuffer;
--
--// // we have caught up with output so all buffers are re-usable
--// if (last != m_iDisplayedRenderBuffer
--// && m_iDisplayedRenderBuffer == m_iOutputRenderBuffer)
--// {
--// CLog::Log(LOGNOTICE,"-------------- all displayed");
--// m_bAllRenderBuffersDisplayed = true;
--// }
-+ m_iDisplayedRenderBuffer = (m_iCurrentRenderBuffer + m_iNumRenderBuffers - 1) % m_iNumRenderBuffers;
-
- if (last != m_iDisplayedRenderBuffer
- && m_iDisplayedRenderBuffer != m_iCurrentRenderBuffer)
-@@ -1044,7 +1025,10 @@ bool CXBMCRenderManager::GetStats(double &sleeptime, double &pts, int &bufferLev
- CSharedLock lock(m_sharedSection);
- sleeptime = m_sleeptime;
- pts = m_presentPts;
-- bufferLevel = (m_iOutputRenderBuffer - m_iCurrentRenderBuffer + m_iNumRenderBuffers) % m_iNumRenderBuffers;
-+ if (m_iNumRenderBuffers < 3)
-+ bufferLevel = -1;
-+ else
-+ bufferLevel = (m_iOutputRenderBuffer - m_iCurrentRenderBuffer + m_iNumRenderBuffers) % m_iNumRenderBuffers;
- return true;
- }
-
-diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h
-index 24f9798..f1fde10 100644
---- a/xbmc/cores/VideoRenderers/RenderManager.h
-+++ b/xbmc/cores/VideoRenderers/RenderManager.h
-@@ -43,7 +43,7 @@
-
- namespace DXVA { class CProcessor; }
- namespace VAAPI { class CSurfaceHolder; }
--namespace VDPAU { struct CVdpauRenderPicture; }
-+namespace VDPAU { class CVdpauRenderPicture; }
- struct DVDVideoPicture;
-
- #define ERRORBUFFSIZE 30
-@@ -242,23 +242,17 @@ class CXBMCRenderManager
- // displayed or even rendered).
- // Current: is the current buffer being or having been submitted for render to back buffer.
- // Cannot go past "Output" buffer (else it would be rendering old output).
-- // FlipRequest: is the render buffer that has last been submitted for render AND importantly has had
-- // swap-buffer flip subsequently invoked (thus flip to front buffer is requested for vblank
-- // subsequent to render completion).
- // Displayed: is the buffer that is now considered to be safely copied from back buffer to front buffer
- // (we assume that after two swap-buffer flips for the same "Current" render buffer that that
- // buffer will be safe, but otherwise we consider that only the previous-to-"Current" is guaranteed).
-- // Last: is the last buffer successfully submitted for render to back buffer (purpose: to rollback to in
-- // unexpected case where a texture render fails).
-
- int m_iCurrentRenderBuffer;
- int m_iNumRenderBuffers;
--// int m_iLastRenderBuffer;
-- int m_iFlipRequestRenderBuffer;
- int m_iOutputRenderBuffer;
- int m_iDisplayedRenderBuffer;
- bool m_bAllRenderBuffersDisplayed;
- bool m_bUseBuffering;
-+ bool m_bCodecSupportsBuffering;
- int m_speed;
- CEvent m_flipEvent;
-
-@@ -284,9 +278,7 @@ class CXBMCRenderManager
- CEvent m_presentevent;
- CEvent m_flushEvent;
- CDVDClock *m_pClock;
-- uint64_t m_rendertime;
-- double m_swaptime;
-- unsigned int m_swapCount;
-+
-
- OVERLAY::CRenderer m_overlays;
-
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-index ce39866..3c2213e 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
-@@ -660,7 +660,7 @@ bool CDVDVideoCodecFFmpeg::GetPictureCommon(DVDVideoPicture* pDvdVideoPicture)
- m_skippedDeint = 0;
-
- m_requestSkipDeint = false;
-- pDvdVideoPicture->iFlags |= m_codecControlState;
-+ pDvdVideoPicture->iFlags |= m_codecControlFlags;
-
- if(!m_started)
- pDvdVideoPicture->iFlags |= DVP_FLAG_DROPPED;
-@@ -882,13 +882,7 @@ unsigned CDVDVideoCodecFFmpeg::GetConvergeCount()
- return 0;
- }
-
--void CDVDVideoCodecFFmpeg::SetSpeed(int speed)
-+void CDVDVideoCodecFFmpeg::SetCodecControl(int flags)
- {
-- if (m_pHardware)
-- m_pHardware->SetSpeed(speed);
--}
--
--void CDVDVideoCodecFFmpeg::SetCodecControl(int state)
--{
-- m_codecControlState = state;
-+ m_codecControlFlags = flags;
- }
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
-index 9bd201a..6ea777d 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
-@@ -45,7 +45,6 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
- virtual int Check (AVCodecContext* avctx) = 0;
- virtual void Reset () {}
- virtual bool CanSkipDeint() {return false; }
-- virtual void SetSpeed(int speed) {}
- virtual const std::string Name() = 0;
- virtual CCriticalSection* Section() { return NULL; }
- };
-@@ -63,8 +62,7 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
- virtual const char* GetName() { return m_name.c_str(); }; // m_name is never changed after open
- virtual unsigned GetConvergeCount();
- virtual bool GetPts(double &pts, int &skippedDeint, int &interlaced) {pts=m_decoderPts; skippedDeint=m_skippedDeint; if (m_pFrame) interlaced = m_pFrame->interlaced_frame; return true;}
-- virtual void SetSpeed(int speed);
-- virtual void SetCodecControl(int state);
-+ virtual void SetCodecControl(int flags);
-
- bool IsHardwareAllowed() { return !m_bSoftware; }
- IHardwareDecoder * GetHardware() { return m_pHardware; };
-@@ -125,6 +123,6 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
- double m_decoderPts, m_decoderInterval;
- int m_skippedDeint;
- bool m_requestSkipDeint;
-- int m_codecControlState;
-+ int m_codecControlFlags;
- std::vector m_formats;
- };
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-index 28dfea0..93e375b 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-@@ -453,9 +453,6 @@ void CDVDPlayerVideo::Process()
- if(m_speed == DVD_PLAYSPEED_PAUSE)
- m_iNrOfPicturesNotToSkip = 0;
- m_droppingStats.Reset();
--// g_renderManager.EnableBuffering(m_speed == DVD_PLAYSPEED_NORMAL);
-- if (m_pVideoCodec)
-- m_pVideoCodec->SetSpeed(m_speed);
- }
- else if (pMsg->IsType(CDVDMsg::PLAYER_STARTED))
- {
-@@ -502,10 +499,9 @@ void CDVDPlayerVideo::Process()
- }
- int codecControl = 0;
- if (iDropDirective & EOS_BUFFER_LEVEL)
-- {
-- if (iDropDirective & EOS_BUFFER_LEVEL)
-- codecControl |= DVP_FLAG_DRAIN;
-- }
-+ codecControl |= DVP_FLAG_DRAIN;
-+ if (m_speed > DVD_PLAYSPEED_NORMAL)
-+ codecControl |= DVP_FLAG_NO_POSTPROC;
- m_pVideoCodec->SetCodecControl(codecControl);
- if (iDropDirective & EOS_DROPPED)
- {
-@@ -567,15 +563,6 @@ void CDVDPlayerVideo::Process()
- }
-
- m_videoStats.AddSampleBytes(pPacket->iSize);
-- // assume decoder dropped a picture if it didn't give us any
-- // picture from a demux packet, this should be reasonable
-- // for libavformat as a demuxer as it normally packetizes
-- // pictures when they come from demuxer
--// if(bRequestDrop && !bPacketDrop && (iDecoderState & VC_BUFFER) && !(iDecoderState & VC_PICTURE))
--// {
--// m_iDroppedFrames++;
--// iDropped++;
--// }
-
- bRequestDrop = false;
-
-@@ -636,7 +623,7 @@ void CDVDPlayerVideo::Process()
- m_iNrOfPicturesNotToSkip--;
- }
-
-- // validate picture timing,
-+ // validate picture timing,
- // if both dts/pts invalid, use pts calulated from picture.iDuration
- // if pts invalid use dts, else use picture.pts as passed
- if (picture.dts == DVD_NOPTS_VALUE && picture.pts == DVD_NOPTS_VALUE)
-@@ -1213,39 +1200,6 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
- m_FlipTimeStamp += max(0.0, iSleepTime);
- m_FlipTimeStamp += iFrameDuration;
-
--// if (iSleepTime <= 0 && m_speed)
--// m_iLateFrames++;
--// else
--// m_iLateFrames = 0;
--//
--// // ask decoder to drop frames next round, as we are very late
--// if(m_iLateFrames > 10)
--// {
--// if (!(pPicture->iFlags & DVP_FLAG_NOSKIP))
--// {
--// //if we're calculating the framerate,
--// //don't drop frames until we've calculated a stable framerate
--// if (m_bAllowDrop || m_speed != DVD_PLAYSPEED_NORMAL)
--// {
--// result |= EOS_VERYLATE;
--// m_pullupCorrection.Flush(); //dropped frames mess up the pattern, so just flush it
--// }
--//
--// //if we requested 5 drops in a row and we're still late, drop on output
--// //this keeps a/v sync if the decoder can't drop, or we're still calculating the framerate
--// if (m_iDroppedRequest > 5)
--// {
--// m_iDroppedRequest--; //decrease so we only drop half the frames
--// return result | EOS_DROPPED;
--// }
--// m_iDroppedRequest++;
--// }
--// }
--// else
--// {
--// m_iDroppedRequest = 0;
--// }
--
- if ((m_droppingStats.m_requestOutputDrop && !(pPicture->iFlags & DVP_FLAG_NOSKIP))
- || (pPicture->iFlags & DVP_FLAG_DROPPED))
- {
-@@ -1648,15 +1602,18 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts)
- // get decoder stats
- if (!m_pVideoCodec->GetPts(iDecoderPts, iSkippedDeint, interlaced))
- iDecoderPts = pts;
-+ if (iDecoderPts == DVD_NOPTS_VALUE)
-+ iDecoderPts = pts;
-
- // get render stats
- g_renderManager.GetStats(iSleepTime, iRenderPts, iBufferLevel);
-
-- if (iBufferLevel < 2)
-+ if (iBufferLevel < 0)
-+ result |= EOS_BUFFER_LEVEL;
-+ else if (iBufferLevel < 2)
- {
- result |= EOS_BUFFER_LEVEL;
-- if (iBufferLevel < 1)
-- CLog::Log(LOGDEBUG,"--------------------- hurry: %d", iBufferLevel);
-+ CLog::Log(LOGDEBUG,"CDVDPlayerVideo::CalcDropRequirement - hurry: %d", iBufferLevel);
- }
-
- bNewFrame = iDecoderPts != m_droppingStats.m_lastDecoderPts;
-@@ -1666,7 +1623,6 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts)
- else
- iInterval = 1/m_fFrameRate*(double)DVD_TIME_BASE;
-
-- // add any gains regardless of being late
- if (m_droppingStats.m_lastDecoderPts > 0
- && bNewFrame
- && m_bAllowDrop
-@@ -1734,7 +1690,6 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts)
- {
- m_droppingStats.m_dropRequests--; //decrease so we only drop half the frames
- m_droppingStats.m_requestOutputDrop = true;
-- CLog::Log(LOGNOTICE,"-------- drop output");
- }
- else if (bNewFrame)
- m_droppingStats.m_dropRequests++;
---
-1.7.10
-
-
-From f5a828fa3fb1f5cfd127cb1bab7bad9f11d70515 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Fri, 31 Aug 2012 15:11:32 +0200
-Subject: [PATCH 03/10] backport some xvba changes
-
----
- xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp | 61 +++++++++++++++----------
- xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h | 3 --
- 2 files changed, 37 insertions(+), 27 deletions(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
-index fa96284..127c958 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
-@@ -21,6 +21,7 @@
-
- #include "system.h"
- #ifdef HAVE_LIBXVBA
-+
- #include
- #include
- #include "XVBA.h"
-@@ -460,7 +461,6 @@ bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned
- m_xvbaBufferPool.data_buffer = 0;
- m_xvbaBufferPool.iq_matrix_buffer = 0;
- m_xvbaBufferPool.picture_descriptor_buffer = 0;
-- picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
- m_presentPicture = 0;
- m_xvbaConfig.numRenderBuffers = surfaces;
- m_decoderThread = CThread::GetCurrentThreadId();
-@@ -573,8 +573,6 @@ bool CDecoder::Supports(EINTERLACEMETHOD method)
-
- void CDecoder::ResetState()
- {
-- picAge.b_age = picAge.ip_age[0] = picAge.ip_age[1] = 256*256*256*64;
--
- m_displayState = XVBA_OPEN;
- }
-
-@@ -730,6 +728,40 @@ bool CDecoder::CreateSession(AVCodecContext* avctx)
-
- void CDecoder::DestroySession()
- {
-+ // wait for unfinished decoding jobs
-+ XbmcThreads::EndTime timer;
-+ if (m_xvbaConfig.xvbaSession)
-+ {
-+ for (unsigned int i = 0; i < m_videoSurfaces.size(); ++i)
-+ {
-+ xvba_render_state *render = m_videoSurfaces[i];
-+ if (render->surface)
-+ {
-+ XVBA_Surface_Sync_Input syncInput;
-+ XVBA_Surface_Sync_Output syncOutput;
-+ syncInput.size = sizeof(syncInput);
-+ syncInput.session = m_xvbaConfig.xvbaSession;
-+ syncInput.surface = render->surface;
-+ syncInput.query_status = XVBA_GET_SURFACE_STATUS;
-+ syncOutput.size = sizeof(syncOutput);
-+ timer.Set(1000);
-+ while(!timer.IsTimePast())
-+ {
-+ if (Success != g_XVBA_vtable.SyncSurface(&syncInput, &syncOutput))
-+ {
-+ CLog::Log(LOGERROR,"XVBA::DestroySession - failed sync surface");
-+ break;
-+ }
-+ if (!(syncOutput.status_flags & XVBA_STILL_PENDING))
-+ break;
-+ Sleep(10);
-+ }
-+ if (timer.IsTimePast())
-+ CLog::Log(LOGERROR,"XVBA::DestroySession - unfinished decoding job");
-+ }
-+ }
-+ }
-+
- m_xvbaOutput.Dispose();
-
- XVBA_Destroy_Decode_Buffers_Input bufInput;
-@@ -1052,7 +1084,6 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
- {
- CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
- CDecoder* xvba = (CDecoder*)ctx->GetHardware();
-- struct pictureAge* pA = &xvba->picAge;
-
- pic->data[0] =
- pic->data[1] =
-@@ -1133,20 +1164,6 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
-
- pic->data[0] = (uint8_t*)render;
-
-- if(pic->reference)
-- {
-- pic->age = pA->ip_age[0];
-- pA->ip_age[0]= pA->ip_age[1]+1;
-- pA->ip_age[1]= 1;
-- pA->b_age++;
-- }
-- else
-- {
-- pic->age = pA->b_age;
-- pA->ip_age[0]++;
-- pA->ip_age[1]++;
-- pA->b_age = 1;
-- }
- pic->type= FF_BUFFER_TYPE_USER;
-
- render->state |= FF_XVBA_STATE_USED_FOR_REFERENCE;
-@@ -1198,11 +1215,7 @@ int CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame)
- m_bufferStats.IncDecoded();
- m_xvbaOutput.m_dataPort.SendOutMessage(COutputDataProtocol::NEWFRAME, &pic, sizeof(pic));
-
-- m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_SKIP_PROC);
-- if (m_codecControl & DVP_FLAG_SKIP_PROC)
-- {
-- m_bufferStats.SetCmd(DVP_FLAG_SKIP_PROC);
-- }
-+ m_codecControl = pic.DVDPic.iFlags & (DVP_FLAG_DRAIN | DVP_FLAG_NO_POSTPROC);
- }
-
- int retval = 0;
-@@ -2328,7 +2341,7 @@ bool COutput::CreateGlxContext()
- XFree(visuals);
-
- m_pixmap = XCreatePixmap(m_Display,
-- DefaultRootWindow(m_Display),
-+ m_Window,
- 192,
- 108,
- visInfo.depth);
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
-index 0abf972..24331e9 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.h
-@@ -33,7 +33,6 @@
- #include "libavcodec/xvba.h"
- #include "utils/ActorProtocol.h"
- #include "settings/VideoSettings.h"
--#include
- #include
- #include
- #include
-@@ -372,8 +371,6 @@ class CDecoder : public CDVDVideoCodecFFmpeg::IHardwareDecoder,
- };
- XVBABufferPool m_xvbaBufferPool;
-
-- pictureAge picAge;
--
- COutput m_xvbaOutput;
- CXvbaBufferStats m_bufferStats;
- CEvent m_inMsgEvent;
---
-1.7.10
-
-
-From d608d480e4159b71e0dfd18f20ba27ecc226fa97 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Fri, 31 Aug 2012 15:12:16 +0200
-Subject: [PATCH 04/10] player and renderer, squash me later
-
----
- xbmc/cores/VideoRenderers/RenderManager.cpp | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp
-index 95372e0..ac31c32 100644
---- a/xbmc/cores/VideoRenderers/RenderManager.cpp
-+++ b/xbmc/cores/VideoRenderers/RenderManager.cpp
-@@ -237,9 +237,9 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi
-
- // check if decoder supports buffering
- m_bCodecSupportsBuffering = false;
-- if (format == DVDVideoPicture::FMT_VDPAU
-- || format == DVDVideoPicture::FMT_VDPAU_420
-- || format == DVDVideoPicture::FMT_XVBA)
-+ if ((flags & DVDVideoPicture::FMT_VDPAU)
-+ || (flags & DVDVideoPicture::FMT_VDPAU_420)
-+ || (flags & DVDVideoPicture::FMT_XVBA))
- m_bCodecSupportsBuffering = true;
-
- bool result = m_pRenderer->Configure(width, height, d_width, d_height, fps, flags, format);
---
-1.7.10
-
-
-From ca91233b8590a6061fe9b24c00ff62ecb96bc333 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Fri, 31 Aug 2012 15:12:45 +0200
-Subject: [PATCH 05/10] ati, fix segfault on exit
-
----
- xbmc/video/VideoReferenceClock.cpp | 12 ++++++++++++
- xbmc/video/VideoReferenceClock.h | 1 +
- 2 files changed, 13 insertions(+)
-
-diff --git a/xbmc/video/VideoReferenceClock.cpp b/xbmc/video/VideoReferenceClock.cpp
-index 24c035b..d0f1ed7 100644
---- a/xbmc/video/VideoReferenceClock.cpp
-+++ b/xbmc/video/VideoReferenceClock.cpp
-@@ -123,6 +123,18 @@
- #endif
- }
-
-+CVideoReferenceClock::~CVideoReferenceClock()
-+{
-+#if defined(HAS_GLX)
-+ // some ATI voodoo, if we don't close the display, we crash on exit
-+ if (m_Dpy)
-+ {
-+ XCloseDisplay(m_Dpy);
-+ m_Dpy = NULL;
-+ }
-+#endif
-+}
-+
- void CVideoReferenceClock::Process()
- {
- bool SetupSuccess = false;
-diff --git a/xbmc/video/VideoReferenceClock.h b/xbmc/video/VideoReferenceClock.h
-index 966af37..742dc79 100644
---- a/xbmc/video/VideoReferenceClock.h
-+++ b/xbmc/video/VideoReferenceClock.h
-@@ -59,6 +59,7 @@ class CVideoReferenceClock : public CThread
- {
- public:
- CVideoReferenceClock();
-+ virtual ~CVideoReferenceClock();
-
- int64_t GetTime(bool interpolated = true);
- int64_t GetFrequency();
---
-1.7.10
-
-
-From 5b5ce20c6902643e4f858a3ca45cefc3e4de05af Mon Sep 17 00:00:00 2001
-From: Joakim Plate
-Date: Sat, 14 Jul 2012 21:00:13 +0200
-Subject: [PATCH 06/10] X11: re-evaluate vsync method after having modified
- window
-
-It could have moved between outputs on different hardware
----
- xbmc/rendering/gl/RenderSystemGL.cpp | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/xbmc/rendering/gl/RenderSystemGL.cpp b/xbmc/rendering/gl/RenderSystemGL.cpp
-index be7dfea..bd8e91b 100644
---- a/xbmc/rendering/gl/RenderSystemGL.cpp
-+++ b/xbmc/rendering/gl/RenderSystemGL.cpp
-@@ -174,6 +174,7 @@ bool CRenderSystemGL::ResetRenderSystem(int width, int height, bool fullScreen,
- {
- m_width = width;
- m_height = height;
-+ m_bVsyncInit = false;
-
- glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
-
---
-1.7.10
-
-
-From c0409779940d74993669788ce0b01d257508a581 Mon Sep 17 00:00:00 2001
-From: Joakim Plate
-Date: Sun, 8 Jul 2012 01:06:05 +0200
-Subject: [PATCH 07/10] [tinyxml] invalid reading of xml from FILE pointers
-
-buf is not a null terminated string, so don't rely on it
----
- xbmc/utils/XBMCTinyXML.cpp | 7 ++-----
- 1 file changed, 2 insertions(+), 5 deletions(-)
-
-diff --git a/xbmc/utils/XBMCTinyXML.cpp b/xbmc/utils/XBMCTinyXML.cpp
-index 82e2451..707653c 100644
---- a/xbmc/utils/XBMCTinyXML.cpp
-+++ b/xbmc/utils/XBMCTinyXML.cpp
-@@ -91,12 +91,9 @@ bool CXBMCTinyXML::LoadFile(FILE *f, TiXmlEncoding encoding)
- {
- CStdString data("");
- char buf[BUFFER_SIZE];
-- int result, count = 0;
-+ int result;
- while ((result = fread(buf, 1, BUFFER_SIZE, f)) > 0)
-- {
-- data.reserve(BUFFER_SIZE * (++count));
-- data.append(buf);
-- }
-+ data.append(buf, result);
- return Parse(data, NULL, encoding) != NULL;
- }
-
---
-1.7.10
-
-
-From aa661e7bd39591141fbab27a4d427db622fa3dbb Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Sun, 2 Sep 2012 10:33:08 +0200
-Subject: [PATCH 08/10] dvdplayer audio: improve a/v when using skip/dupe
- method, duration of packets may be too long for
- proper sync
-
----
- xbmc/cores/dvdplayer/DVDPlayerAudio.cpp | 20 ++++++++++++++++----
- 1 file changed, 16 insertions(+), 4 deletions(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
-index 9f2128c..0e4adaa 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
-@@ -719,7 +719,7 @@ void CDVDPlayerAudio::HandleSyncError(double duration)
-
- //check if measured error for 1 second
- now = CurrentHostCounter();
-- if ((now - m_errortime) >= m_freq)
-+ if ((now - m_errortime) >= m_freq * 2)
- {
- m_errortime = now;
- m_error = m_errorbuff / m_errorcount;
-@@ -759,9 +759,21 @@ void CDVDPlayerAudio::HandleSyncError(double duration)
- {
- //check how many packets to skip/duplicate
- m_skipdupcount = (int)(m_error / duration);
-- //if less than one frame off, see if it's more than two thirds of a frame, so we can get better in sync
-- if (m_skipdupcount == 0 && fabs(m_error) > duration / 3 * 2)
-- m_skipdupcount = (int)(m_error / (duration / 3 * 2));
-+
-+ if (m_skipdupcount == 0)
-+ {
-+ double delay;
-+ if (m_error < 0)
-+ {
-+ m_skipdupcount -= 1;
-+ delay = ((double)DVD_TIME_TO_MSEC(duration + m_error)) / 1000;
-+ }
-+ else
-+ {
-+ delay = ((double)DVD_TIME_TO_MSEC(m_error)) / 1000;
-+ }
-+ m_dvdAudio.AddSilence(delay);
-+ }
-
- if (m_skipdupcount > 0)
- CLog::Log(LOGDEBUG, "CDVDPlayerAudio:: Duplicating %i packet(s) of %.2f ms duration",
---
-1.7.10
-
-
-From 68b93215319f4ad4d0ee72797f82214ff8490379 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Sun, 2 Sep 2012 16:05:21 +0200
-Subject: [PATCH 09/10] video player: present correct pts to user for a/v sync
-
----
- xbmc/cores/dvdplayer/DVDPlayerVideo.cpp | 57 ++++++++++++++++++++++---------
- xbmc/cores/dvdplayer/DVDPlayerVideo.h | 2 +-
- 2 files changed, 42 insertions(+), 17 deletions(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-index 93e375b..7e39690 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-@@ -1183,22 +1183,22 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
- iSleepTime = iFrameSleep;
- else
- iSleepTime = iFrameSleep + (iClockSleep - iFrameSleep) / m_autosync;
--
--#ifdef PROFILE /* during profiling, try to play as fast as possible */
-- iSleepTime = 0;
--#endif
--
-- // present the current pts of this frame to user, and include the actual
-- // presentation delay, to allow him to adjust for it
-- if( m_stalled )
-- m_iCurrentPts = DVD_NOPTS_VALUE;
-- else
-- m_iCurrentPts = pts - max(0.0, iSleepTime);
--
-- // timestamp when we think next picture should be displayed based on current duration
-- m_FlipTimeStamp = iCurrentClock;
-- m_FlipTimeStamp += max(0.0, iSleepTime);
-- m_FlipTimeStamp += iFrameDuration;
-+//
-+//#ifdef PROFILE /* during profiling, try to play as fast as possible */
-+// iSleepTime = 0;
-+//#endif
-+//
-+// // present the current pts of this frame to user, and include the actual
-+// // presentation delay, to allow him to adjust for it
-+// if( m_stalled )
-+// m_iCurrentPts = DVD_NOPTS_VALUE;
-+// else
-+// m_iCurrentPts = pts - max(0.0, iSleepTime);
-+//
-+// // timestamp when we think next picture should be displayed based on current duration
-+// m_FlipTimeStamp = iCurrentClock;
-+// m_FlipTimeStamp += max(0.0, iSleepTime);
-+// m_FlipTimeStamp += iFrameDuration;
-
- if ((m_droppingStats.m_requestOutputDrop && !(pPicture->iFlags & DVP_FLAG_NOSKIP))
- || (pPicture->iFlags & DVP_FLAG_DROPPED))
-@@ -1505,6 +1505,22 @@ void CDVDPlayerVideo::ResetFrameRateCalc()
- g_advancedSettings.m_videoFpsDetect == 0;
- }
-
-+double CDVDPlayerVideo::GetCurrentPts()
-+{
-+ double iSleepTime, iRenderPts;
-+ int iBufferLevel;
-+
-+ // get render stats
-+ g_renderManager.GetStats(iSleepTime, iRenderPts, iBufferLevel);
-+
-+ if( m_stalled )
-+ iRenderPts = DVD_NOPTS_VALUE;
-+ else
-+ iRenderPts = iRenderPts - max(0.0, iSleepTime);
-+
-+ return iRenderPts;
-+}
-+
- #define MAXFRAMERATEDIFF 0.01
- #define MAXFRAMESERR 1000
-
-@@ -1623,6 +1639,15 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts)
- else
- iInterval = 1/m_fFrameRate*(double)DVD_TIME_BASE;
-
-+
-+ m_FlipTimeStamp = m_pClock->GetAbsoluteClock() + max(0.0, iSleepTime) + iInterval;
-+
-+ if( m_stalled )
-+ m_iCurrentPts = DVD_NOPTS_VALUE;
-+ else
-+ m_iCurrentPts = iRenderPts - max(0.0, iSleepTime);
-+
-+
- if (m_droppingStats.m_lastDecoderPts > 0
- && bNewFrame
- && m_bAllowDrop
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.h b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
-index a0322dc..6fff15c 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerVideo.h
-+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.h
-@@ -106,7 +106,7 @@ class CDVDPlayerVideo : public CThread
-
- bool InitializedOutputDevice();
-
-- double GetCurrentPts() { return m_iCurrentPts; }
-+ double GetCurrentPts();
- int GetPullupCorrection() { return m_pullupCorrection.GetPatternLength(); }
-
- double GetOutputDelay(); /* returns the expected delay, from that a packet is put in queue */
---
-1.7.10
-
-
-From b38863d14fb42fe86d0e53d9d34d84e1b9eb6907 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Tue, 4 Sep 2012 08:55:36 +0200
-Subject: [PATCH 10/10] vdpau: disable interop yuv and studio level
-
----
- xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 10 +++++-----
- xbmc/settings/GUISettings.cpp | 4 ++--
- 2 files changed, 7 insertions(+), 7 deletions(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-index 16edf55..04ad61d 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
-@@ -366,7 +366,7 @@ bool CDecoder::Supports(EINTERLACEMETHOD method)
- || method == VS_INTERLACEMETHOD_AUTO)
- return true;
-
-- if (g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv"))
-+ if (0) //g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv"))
- {
- if (method == VS_INTERLACEMETHOD_RENDER_BOB)
- return true;
-@@ -1697,7 +1697,7 @@ void CMixer::SetColor()
- //vdp_st = vdp_generate_csc_matrix(&m_Procamp, VDP_COLOR_STANDARD_ITUR_BT_601, &m_CSCMatrix);
-
- VdpVideoMixerAttribute attributes[] = { VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX };
-- if (g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
-+ if (0) //g_guiSettings.GetBool("videoplayer.vdpaustudiolevel"))
- {
- float studioCSC[3][4];
- GenerateStudioCSCMatrix(colorStandard, studioCSC);
-@@ -1846,7 +1846,7 @@ void CMixer::SetDeinterlacing()
-
- SetDeintSkipChroma();
-
-- m_config.useInteropYuv = g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
-+ m_config.useInteropYuv = false; //g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
- }
-
- void CMixer::SetDeintSkipChroma()
-@@ -2038,7 +2038,7 @@ void CMixer::Init()
- m_vdpError = false;
-
- m_config.upscale = g_advancedSettings.m_videoVDPAUScaling;
-- m_config.useInteropYuv = g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
-+ m_config.useInteropYuv = false; //g_guiSettings.GetBool("videoplayer.usevdpauinteropyuv");
-
- CreateVdpauMixer();
- }
-@@ -3215,7 +3215,7 @@ bool COutput::GLInit()
- {
- m_config.usePixmaps = true;
- g_guiSettings.SetBool("videoplayer.usevdpauinterop",false);
-- g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
-+// g_guiSettings.SetBool("videoplayer.usevdpauinteropyuv",false);
- }
- if (!glXBindTexImageEXT)
- glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT");
-diff --git a/xbmc/settings/GUISettings.cpp b/xbmc/settings/GUISettings.cpp
-index 2d79423..e29c8c1 100644
---- a/xbmc/settings/GUISettings.cpp
-+++ b/xbmc/settings/GUISettings.cpp
-@@ -598,7 +598,7 @@ void CGUISettings::Initialize()
- #ifdef HAVE_LIBVDPAU
- AddBool(vp, "videoplayer.usevdpau", 13425, true);
- AddBool(vp, "videoplayer.usevdpauinterop", 13433, true);
-- AddBool(vp, "videoplayer.usevdpauinteropyuv", 13434, true);
-+// AddBool(vp, "videoplayer.usevdpauinteropyuv", 13434, true);
- #endif
- #ifdef HAVE_LIBVA
- AddBool(vp, "videoplayer.usevaapi", 13426, true);
-@@ -672,7 +672,7 @@ void CGUISettings::Initialize()
- AddSeparator(vp, "videoplayer.sep1.5");
- #ifdef HAVE_LIBVDPAU
- AddBool(NULL, "videoplayer.vdpauUpscalingLevel", 13121, false);
-- AddBool(vp, "videoplayer.vdpaustudiolevel", 13122, false);
-+// AddBool(vp, "videoplayer.vdpaustudiolevel", 13122, false);
- #endif
- #endif
- AddSeparator(vp, "videoplayer.sep5");
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.22-videoplayer_fix_calcDropRequirement_for_forced_deinterlacing.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.22-videoplayer_fix_calcDropRequirement_for_forced_deinterlacing.patch
deleted file mode 100644
index 01043f4e81..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.22-videoplayer_fix_calcDropRequirement_for_forced_deinterlacing.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From 66a8245d4e7d02469f03c6a1b3e295dde346645f Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Sat, 15 Sep 2012 17:24:30 +0200
-Subject: [PATCH] videoplayer: fix calcDropRequirement for forced
- deinterlacing
-
----
- xbmc/cores/dvdplayer/DVDPlayerVideo.cpp | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-index db0fb1f..81e0012 100644
---- a/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-+++ b/xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
-@@ -1702,7 +1702,7 @@ int CDVDPlayerVideo::CalcDropRequirement(double pts)
-
- bNewFrame = iDecoderPts != m_droppingStats.m_lastDecoderPts;
-
-- if (interlaced)
-+ if (interlaced || iSkippedDeint)
- iInterval = 2/m_fFrameRate*(double)DVD_TIME_BASE;
- else
- iInterval = 1/m_fFrameRate*(double)DVD_TIME_BASE;
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.23-vdpau_fix_AutoInterlaceMethod_to_prevent_from_double_de-interlacing.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.23-vdpau_fix_AutoInterlaceMethod_to_prevent_from_double_de-interlacing.patch
deleted file mode 100644
index 620eb0a651..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.23-vdpau_fix_AutoInterlaceMethod_to_prevent_from_double_de-interlacing.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-From f0bf2b7dff16ac6ee875770b390accf71660a662 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Sun, 16 Sep 2012 08:27:06 +0200
-Subject: [PATCH] vdpau: fix AutoInterlaceMethod to prevent from double
- de-interlacing
-
----
- xbmc/cores/VideoRenderers/LinuxRendererGL.cpp | 7 -------
- 1 file changed, 7 deletions(-)
-
-diff --git a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-index f25252c..374d75d 100644
---- a/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-+++ b/xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
-@@ -3743,14 +3743,7 @@ EINTERLACEMETHOD CLinuxRendererGL::AutoInterlaceMethod()
- return VS_INTERLACEMETHOD_NONE;
-
- if(m_renderMethod & RENDER_VDPAU)
-- {
--#ifdef HAVE_LIBVDPAU
-- VDPAU::CVdpauRenderPicture *vdpauPic = m_buffers[m_iYV12RenderBuffer].vdpau;
-- if(vdpauPic && vdpauPic->vdpau)
-- return vdpauPic->vdpau->AutoInterlaceMethod();
--#endif
- return VS_INTERLACEMETHOD_NONE;
-- }
-
- if(Supports(VS_INTERLACEMETHOD_RENDER_BOB))
- return VS_INTERLACEMETHOD_RENDER_BOB;
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.24-xvba_oopsie.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.24-xvba_oopsie.patch
deleted file mode 100644
index 9139fd4ddc..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-902.24-xvba_oopsie.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-From a7d40418f3aaf35f5df1de8987ce14afd59fb04f Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Sun, 16 Sep 2012 12:19:27 +0200
-Subject: [PATCH] xvba: oopsie :)
-
----
- xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
-index d4cf6cf..bd7cc3d 100644
---- a/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
-+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/XVBA.cpp
-@@ -768,6 +768,7 @@ void CDecoder::DestroySession()
- XVBA_Destroy_Decode_Buffers_Input bufInput;
- bufInput.size = sizeof(bufInput);
- bufInput.num_of_buffers_in_list = 1;
-+ bufInput.session = m_xvbaConfig.xvbaSession;
-
- for (unsigned int i=0; i
-Date: Sun, 16 Sep 2012 18:38:01 +0200
-Subject: [PATCH] vdpau: fix upscaling setting
-
----
- xbmc/settings/AdvancedSettings.cpp | 4 ++--
- xbmc/settings/AdvancedSettings.h | 2 +-
- 2 files changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp
-index 61ccf85..3556b7d 100644
---- a/xbmc/settings/AdvancedSettings.cpp
-+++ b/xbmc/settings/AdvancedSettings.cpp
-@@ -98,7 +98,7 @@ void CAdvancedSettings::Initialize()
- m_videoIgnoreSecondsAtStart = 3*60;
- m_videoIgnorePercentAtEnd = 8.0f;
- m_videoPlayCountMinimumPercent = 90.0f;
-- m_videoVDPAUScaling = false;
-+ m_videoVDPAUScaling = -1;
- m_videoNonLinStretchRatio = 0.5f;
- m_videoEnableHighQualityHwScalers = false;
- m_videoAutoScaleMaxFps = 30.0f;
-@@ -492,7 +492,7 @@ void CAdvancedSettings::ParseSettingsFile(const CStdString &file)
- XMLUtils::GetString(pElement,"cleandatetime", m_videoCleanDateTimeRegExp);
- XMLUtils::GetString(pElement,"ppffmpegdeinterlacing",m_videoPPFFmpegDeint);
- XMLUtils::GetString(pElement,"ppffmpegpostprocessing",m_videoPPFFmpegPostProc);
-- XMLUtils::GetBoolean(pElement,"vdpauscaling",m_videoVDPAUScaling);
-+ XMLUtils::GetInt(pElement,"vdpauscaling",m_videoVDPAUScaling);
- XMLUtils::GetFloat(pElement, "nonlinearstretchratio", m_videoNonLinStretchRatio, 0.01f, 1.0f);
- XMLUtils::GetBoolean(pElement,"enablehighqualityhwscalers", m_videoEnableHighQualityHwScalers);
- XMLUtils::GetFloat(pElement,"autoscalemaxfps",m_videoAutoScaleMaxFps, 0.0f, 1000.0f);
-diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h
-index b3a54ff..f50151a 100644
---- a/xbmc/settings/AdvancedSettings.h
-+++ b/xbmc/settings/AdvancedSettings.h
-@@ -152,7 +152,7 @@ class CAdvancedSettings
- CStdString m_audioHost;
- bool m_audioApplyDrc;
-
-- bool m_videoVDPAUScaling;
-+ int m_videoVDPAUScaling;
- float m_videoNonLinStretchRatio;
- bool m_videoEnableHighQualityHwScalers;
- float m_videoAutoScaleMaxFps;
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch
deleted file mode 100644
index 0cfaf7fff4..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-903.01-fixed_still_frames_at_the_start_of_a_VTS_in_dvd_could_end_up_not_showing.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-From 497941802e56121adf03428d964e225c80989afd Mon Sep 17 00:00:00 2001
-From: elupus
-Date: Sat, 7 Apr 2012 00:08:34 +0200
-Subject: [PATCH] fixed: still frames at the start of a VTS in dvd could end
- up not showing
-
-This occured due to a change in behavior in updated ffmpeg. Old code would
-return EOF once after a VTS change to trigger demuxer flush, however
-updated ffmpeg will read multiple times causing demuxer reset actions
-to get executed after actual data having been processed by demuxer.
----
- .../cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
-
-diff --git a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
-index dbdff52..3ae4843 100644
---- a/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
-+++ b/xbmc/cores/dvdplayer/DVDInputStreams/DVDInputStreamNavigator.cpp
-@@ -419,9 +419,12 @@ int CDVDInputStreamNavigator::ProcessBlock(BYTE* dest_buffer, int* read)
- iNavresult = NAVRESULT_HOLD;
- }
- else
-+ {
- iNavresult = m_pDVDPlayer->OnDVDNavResult(buf, DVDNAV_VTS_CHANGE);
--
-- m_bInMenu = (0 == m_dll.dvdnav_is_domain_vts(m_dvdnav));
-+ m_holdmode = HOLDMODE_HELD;
-+ m_lastevent = DVDNAV_NOP;
-+ m_bInMenu = (0 == m_dll.dvdnav_is_domain_vts(m_dvdnav));
-+ }
- }
- break;
-
---
-1.7.10
-
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-981-toggleButtonState.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-981-toggleButtonState.patch
deleted file mode 100644
index 17a606f1b1..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-981-toggleButtonState.patch
+++ /dev/null
@@ -1,304 +0,0 @@
-diff -Naur xbmc-f3b0020/xbmc/guilib/GUIToggleButtonControl.h xbmc-f3b0020.patch/xbmc/guilib/GUIToggleButtonControl.h
---- xbmc-f3b0020/xbmc/guilib/GUIToggleButtonControl.h 2011-12-10 22:16:22.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/guilib/GUIToggleButtonControl.h 2011-12-17 18:43:42.183704449 +0100
-@@ -57,6 +57,7 @@
- virtual CStdString GetDescription() const;
- void SetToggleSelect(const CStdString &toggleSelect);
- void SetAltClickActions(const CGUIAction &clickActions);
-+ bool IsSelected() const { return m_bSelected; };
-
- protected:
- virtual bool UpdateColors();
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/control.h xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/control.h
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/control.h 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/control.h 2011-12-17 18:43:42.216705084 +0100
-@@ -135,6 +135,11 @@
-
- typedef struct {
- PyObject_HEAD_XBMC_CONTROL
-+ bool bIsSelected;
-+ } ControlToggle;
-+
-+ typedef struct {
-+ PyObject_HEAD_XBMC_CONTROL
- std::string strFont;
- color_t textColor;
- std::vector vecLabels;
-@@ -263,7 +268,8 @@
- extern PyTypeObject ControlRadioButton_Type;
- extern PyTypeObject ControlSlider_Type;
- extern PyTypeObject ControlEdit_Type;
--
-+ extern PyTypeObject ControlToggle_Type;
-+
- CGUIControl* ControlLabel_Create(ControlLabel* pControl);
- CGUIControl* ControlFadeLabel_Create(ControlFadeLabel* pControl);
- CGUIControl* ControlTextBox_Create(ControlTextBox* pControl);
-@@ -276,6 +282,7 @@
- CGUIControl* ControlRadioButton_Create(ControlRadioButton* pControl);
- CGUIControl* ControlSlider_Create(ControlSlider* pControl);
- CGUIControl* ControlEdit_Create(ControlEdit* pControl);
-+ CGUIControl* ControlToggle_Create(ControlToggle* pControl);
-
- void initControl_Type();
- void initControlSpin_Type();
-@@ -291,6 +298,7 @@
- void initControlRadioButton_Type();
- void initControlSlider_Type();
- void initControlEdit_Type();
-+ void initControlToggle_Type();
- }
-
- #ifdef __cplusplus
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp 1970-01-01 01:00:00.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/controltogglebutton.cpp 2011-12-17 18:43:42.217705104 +0100
-@@ -0,0 +1,181 @@
-+/*
-+ * Copyright (C) 2005-2011 Team XBMC
-+ * http://www.xbmc.org
-+ *
-+ * This Program 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, or (at your option)
-+ * any later version.
-+ *
-+ * This Program 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 XBMC; see the file COPYING. If not, write to
-+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-+ * http://www.gnu.org/copyleft/gpl.html
-+ *
-+ */
-+
-+#include
-+
-+#include "guilib/GUIToggleButtonControl.h"
-+#include "guilib/GUIFontManager.h"
-+#include "control.h"
-+#include "pyutil.h"
-+
-+using namespace std;
-+
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+namespace PYXBMC
-+{
-+ PyObject* ControlToggle_New(
-+ PyTypeObject *type,
-+ PyObject *args,
-+ PyObject *kwds )
-+ {
-+ static const char *keywords[] = {
-+ "x", "y", "width", "height", "label",
-+ "focusTexture", "noFocusTexture",
-+ "textOffsetX", "textOffsetY", "alignment",
-+ "font", "textColor", "disabledColor", "angle", "shadowColor", "focusedColor", NULL };
-+ ControlToggle *self;
-+ char* cFont = NULL;
-+ char* cTextureFocus = NULL;
-+ char* cTextureNoFocus = NULL;
-+ char* cTextColor = NULL;
-+ char* cDisabledColor = NULL;
-+ char* cShadowColor = NULL;
-+ char* cFocusedColor = NULL;
-+
-+ PyObject* pObjectText;
-+
-+ self = (ControlToggle*)type->tp_alloc(type, 0);
-+ if (!self) return NULL;
-+ new(&self->bIsSelected) bool();
-+
-+ if (!PyArg_ParseTupleAndKeywords(
-+ args,
-+ kwds,
-+ (char*)"llllO|sslllssslss",
-+ (char**)keywords,
-+ &self->dwPosX,
-+ &self->dwPosY,
-+ &self->dwWidth,
-+ &self->dwHeight,
-+ &pObjectText,
-+ &cTextureFocus,
-+ &cTextureNoFocus,
-+ &cFont,
-+ &cTextColor,
-+ &cDisabledColor,
-+ &cShadowColor,
-+ &cFocusedColor))
-+ {
-+ Py_DECREF( self );
-+ return NULL;
-+ }
-+
-+
-+ cTextureFocus :
-+ PyXBMCGetDefaultImage((char*)"button", (char*)"texturefocus", (char*)"button-focus.png");
-+ cTextureNoFocus :
-+ PyXBMCGetDefaultImage((char*)"button", (char*)"texturenofocus", (char*)"button-nofocus.jpg");
-+
-+ return (PyObject*)self;
-+ }
-+
-+ void ControlToggle_Dealloc(ControlToggle* self)
-+ {
-+ self->ob_type->tp_free((PyObject*)self);
-+ }
-+
-+
-+ // isSelected() Method
-+ PyDoc_STRVAR(isSelected__doc__,
-+ "isSelected() -- Returns the toggle buttons's selected status.\n"
-+ "\n"
-+ "example:\n"
-+ " - is = self.togglebutton.isSelected()\n");
-+
-+ PyObject* ControlToggle_IsSelected(ControlToggle *self, PyObject *args)
-+ {
-+ bool isSelected = false;
-+
-+ PyXBMCGUILock();
-+ if (self->pGUIControl)
-+ isSelected = ((CGUIToggleButtonControl*)self->pGUIControl)->IsSelected();
-+ PyXBMCGUIUnlock();
-+
-+ return Py_BuildValue((char*)"b", isSelected);
-+ }
-+
-+
-+ PyMethodDef ControlToggle_methods[] = {
-+ {(char*)"isSelected", (PyCFunction)ControlToggle_IsSelected, METH_VARARGS, isSelected__doc__},
-+ {NULL, NULL, 0, NULL}
-+ };
-+
-+ // ControlRadioButton class
-+ PyDoc_STRVAR(ControlToggle__doc__,
-+ "ControlRadioButton class.\n"
-+ "\n"
-+ "ControlRadioButton(x, y, width, height, label[, focusTexture, noFocusTexture, textOffsetX, textOffsetY,\n"
-+ " alignment, font, textColor, disabledColor, angle, shadowColor, focusedColor,\n"
-+ " radioFocusTexture, noRadioFocusTexture])\n"
-+ "\n"
-+ "x : integer - x coordinate of control.\n"
-+ "y : integer - y coordinate of control.\n"
-+ "width : integer - width of control.\n"
-+ "height : integer - height of control.\n"
-+ "label : string or unicode - text string.\n"
-+ "focusTexture : [opt] string - filename for focus texture.\n"
-+ "noFocusTexture : [opt] string - filename for no focus texture.\n"
-+ "textOffsetX : [opt] integer - x offset of label.\n"
-+ "textOffsetY : [opt] integer - y offset of label.\n"
-+ "alignment : [opt] integer - alignment of label - *Note, see xbfont.h\n"
-+ "font : [opt] string - font used for label text. (e.g. 'font13')\n"
-+ "textColor : [opt] hexstring - color of enabled radio button's label. (e.g. '0xFFFFFFFF')\n"
-+ "disabledColor : [opt] hexstring - color of disabled radio button's label. (e.g. '0xFFFF3300')\n"
-+ "angle : [opt] integer - angle of control. (+ rotates CCW, - rotates CW)\n"
-+ "shadowColor : [opt] hexstring - color of radio button's label's shadow. (e.g. '0xFF000000')\n"
-+ "focusedColor : [opt] hexstring - color of focused radio button's label. (e.g. '0xFF00FFFF')\n"
-+ "radioFocusTexture : [opt] string - filename for radio focus texture.\n"
-+ "noRadioFocusTexture : [opt] string - filename for radio no focus texture.\n"
-+ "\n"
-+ "*Note, You can use the above as keywords for arguments and skip certain optional arguments.\n"
-+ " Once you use a keyword, all following arguments require the keyword.\n"
-+ " After you create the control, you need to add it to the window with addControl().\n"
-+ "\n"
-+ "example:\n"
-+ " - self.radiobutton = xbmcgui.ControlToggleButton(100, 250, 200, 50, 'Status', font='font14')\n");
-+
-+ // Restore code and data sections to normal.
-+
-+ PyTypeObject ControlToggle_Type;
-+
-+ void initControlToggle_Type()
-+ {
-+ PyXBMCInitializeTypeObject(&ControlToggle_Type);
-+
-+ ControlToggle_Type.tp_name = (char*)"xbmcgui.ControlToggleButton";
-+ ControlToggle_Type.tp_basicsize = sizeof(ControlToggle);
-+ ControlToggle_Type.tp_dealloc = (destructor)ControlToggle_Dealloc;
-+ ControlToggle_Type.tp_compare = 0;
-+ ControlToggle_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
-+ ControlToggle_Type.tp_doc = ControlToggle__doc__;
-+ ControlToggle_Type.tp_methods = ControlToggle_methods;
-+ ControlToggle_Type.tp_base = &Control_Type;
-+ ControlToggle_Type.tp_new = ControlToggle_New;
-+ }
-+}
-+
-+#ifdef __cplusplus
-+}
-+#endif
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/Makefile.in xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/Makefile.in
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/Makefile.in 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/Makefile.in 2011-12-17 18:44:47.447960296 +0100
-@@ -13,6 +13,7 @@
- controlslider.cpp \
- controlspin.cpp \
- controltextbox.cpp \
-+ controltogglebutton.cpp \
- dialog.cpp \
- GUIPythonWindow.cpp \
- GUIPythonWindowDialog.cpp \
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/window.cpp xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/window.cpp
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/window.cpp 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/window.cpp 2011-12-17 18:43:42.218705123 +0100
-@@ -277,6 +277,12 @@
- if (li.font) ((ControlEdit*)pControl)->strFont = li.font->GetFontName();
- ((ControlButton*)pControl)->align = li.align;
- break;
-+ case CGUIControl::GUICONTROL_TOGGLEBUTTON:
-+ pControl = (Control*)ControlToggle_Type.tp_alloc(&ControlToggle_Type, 0);
-+ new(&((ControlToggle*)pControl)->bIsSelected) bool();
-+
-+ break;
-+
- default:
- break;
- }
-diff -Naur xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp
---- xbmc-f3b0020/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp 2011-12-10 22:16:21.000000000 +0100
-+++ xbmc-f3b0020.patch/xbmc/interfaces/python/xbmcmodule/xbmcguimodule.cpp 2011-12-17 18:43:42.219705142 +0100
-@@ -138,6 +138,7 @@
- initAction_Type();
- initControlRadioButton_Type();
- initControlEdit_Type();
-+ initControlToggle_Type();
-
- if (PyType_Ready(&Window_Type) < 0 ||
- PyType_Ready(&WindowDialog_Type) < 0 ||
-@@ -160,7 +161,8 @@
- PyType_Ready(&ControlSlider_Type) < 0 ||
- PyType_Ready(&ControlRadioButton_Type) < 0 ||
- PyType_Ready(&ControlEdit_Type) < 0 ||
-- PyType_Ready(&Action_Type) < 0)
-+ PyType_Ready(&Action_Type) < 0 ||
-+ PyType_Ready(&ControlToggle_Type) < 0)
- return;
-
- }
-@@ -200,6 +202,7 @@
- Py_INCREF(&Action_Type);
- Py_INCREF(&ControlRadioButton_Type);
- Py_INCREF(&ControlEdit_Type);
-+ Py_INCREF(&ControlToggle_Type);
-
- pXbmcGuiModule = Py_InitModule3((char*)"xbmcgui", xbmcGuiMethods, xbmcgui_module_documentation);
-
-@@ -227,7 +230,8 @@
- PyModule_AddObject(pXbmcGuiModule, (char*)"Action", (PyObject *)&Action_Type);
- PyModule_AddObject(pXbmcGuiModule, (char*)"ControlRadioButton", (PyObject*)&ControlRadioButton_Type);
- PyModule_AddObject(pXbmcGuiModule, (char*)"ControlEdit", (PyObject*)&ControlEdit_Type);
--
-+ PyModule_AddObject(pXbmcGuiModule, (char*)"ControlToggle", (PyObject*)&ControlToggle_Type);
-+
- PyModule_AddStringConstant(pXbmcGuiModule, (char*)"__author__", (char*)PY_XBMC_AUTHOR);
- PyModule_AddStringConstant(pXbmcGuiModule, (char*)"__date__", (char*)"14 July 2006");
- PyModule_AddStringConstant(pXbmcGuiModule, (char*)"__version__", (char*)"1.2");
-diff -Naur xbmc-f3b0020/XBMC.xcodeproj/project.pbxproj xbmc-f3b0020.patch/XBMC.xcodeproj/project.pbxproj
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch
deleted file mode 100644
index 8a8a5d49e8..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-982-UDisk-device-must-be-remount-in-DeviceChanged-event.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f025c39679b438cb91a0ef0f205736ff92fddeac Mon Sep 17 00:00:00 2001
-From: Vic Lee
-Date: Thu, 10 Feb 2011 09:36:15 +0800
-Subject: [PATCH 5/5] UDisk: device must be remount in DeviceChanged event
-
-
-Signed-off-by: Vic Lee
----
- xbmc/linux/UDisksProvider.cpp | 2 ++
- 1 files changed, 2 insertions(+), 0 deletions(-)
-
-diff --git a/xbmc/storage/linux/UDisksProvider.cpp b/xbmc/storage/linux/UDisksProvider.cpp
-index 8e9b378..e24502a 100644
---- a/xbmc/storage/linux/UDisksProvider.cpp
-+++ b/xbmc/storage/linux/UDisksProvider.cpp
-@@ -368,6 +368,8 @@ void CUDisksProvider::DeviceChanged(const char *object, IStorageEventsCallback *
- {
- bool mounted = device->m_isMounted;
- device->Update();
-+ if (g_advancedSettings.m_handleMounting)
-+ device->Mount();
- if (!mounted && device->m_isMounted && callback)
- callback->OnStorageAdded(device->m_Label, device->m_MountPath);
- else if (mounted && !device->m_isMounted && callback)
---
-1.7.2.3
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch
deleted file mode 100644
index 24af12df39..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-983-fixed-failure-to-broswe-for-smb-shares.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From f52dd9a555e8e4b087ec6fbf040dc1f1155c4136 Mon Sep 17 00:00:00 2001
-From: "S. Davilla"
-Date: Sat, 21 Apr 2012 14:11:56 -0400
-Subject: [PATCH] fixed, failure to broswe for smb shares. this hits all 1st
- time installs
-
----
- xbmc/filesystem/SmbFile.cpp | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/xbmc/filesystem/FileSmb.cpp b/xbmc/filesystem/FileSmb.cpp
-index 382553c..c390031 100644
---- a/xbmc/filesystem/FileSmb.cpp
-+++ b/xbmc/filesystem/FileSmb.cpp
-@@ -61,7 +61,6 @@ SMBCSRV* xb_smbc_cache(SMBCCTX* c, const char* server, const char* share, const
- m_IdleTimeout = 0;
- #endif
- m_context = NULL;
-- smbc_init(xb_smbc_auth, 0);
- }
-
- CSMB::~CSMB()
-@@ -149,6 +148,10 @@ void CSMB::Init()
- }
- #endif
-
-+ // reads smb.conf so this MUST be after we create smb.conf
-+ // multiple smbc_init calls are ignored by libsmbclient.
-+ smbc_init(xb_smbc_auth, 0);
-+
- #ifdef TARGET_WINDOWS
- // set the log function
- set_log_callback(xb_smbc_log);
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch
deleted file mode 100644
index 6163872d60..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-984-do-not-remount-non-optical-devices-in-DeviceChanged-event.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/xbmc/storage/linux/UDisksProvider.cpp b/xbmc/storage/linux/UDisksProvider.cpp
-index 6afc1a8..c940e69 100644
---- a/xbmc/storage/linux/UDisksProvider.cpp
-+++ b/xbmc/storage/linux/UDisksProvider.cpp
-@@ -356,7 +356,7 @@ void CUDisksProvider::DeviceChanged(const char *object, IStorageEventsCallback *
- {
- bool mounted = device->m_isMounted;
- device->Update();
-- if (g_advancedSettings.m_handleMounting)
-+ if (g_advancedSettings.m_handleMounting && device->m_isOptical)
- device->Mount();
- if (!mounted && device->m_isMounted && callback)
- callback->OnStorageAdded(device->m_Label, device->m_MountPath);
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-990-wiimote.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-990-wiimote.patch
deleted file mode 100644
index 05379ebdf6..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-990-wiimote.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h b/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h
-index dbdbb94..6f68715 100644
---- a/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h
-+++ b/tools/EventClients/Clients/WiiRemote/WiiUse_WiiRemote.h
-@@ -27,7 +27,7 @@
- #include "../../lib/c++/xbmcclient.h"
- #endif
- //#ifndef WIN32
--// #include
-+ #include
- //#endif
- #include "wiiuse.h"
- //#define ICON_PATH "../../"
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999-crosscompile.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999-crosscompile.patch
deleted file mode 100644
index 9c73a9644e..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999-crosscompile.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff --git a/Makefile.include.in b/Makefile.include.in
-index b70245d..0537b86 100644
---- a/Makefile.include.in
-+++ b/Makefile.include.in
-@@ -1,4 +1,4 @@
--AR=ar
-+AR=@AR@
- ARFLAGS=crus
- RM=rm -rf
- SHELL=@SHELL@
-diff --git a/configure.in b/configure.in
-index 7348529..baea8e0 100755
---- a/configure.in
-+++ b/configure.in
-@@ -22,7 +22,7 @@ AC_DEFUN([XB_FIND_SONAME],
- AC_MSG_CHECKING([for lib$2 soname])
- $1_FILENAME=$($CC -nostdlib -o /dev/null $LDFLAGS -l$2 -Wl,-M 2>/dev/null | grep "^LOAD.*$2" | awk '{V=2; print $V}')
- if [[ ! -z $$1_FILENAME ]]; then
-- $1_SONAME=$(objdump -p $$1_FILENAME | grep "SONAME.*$2" | awk '{V=2; print $V}')
-+ $1_SONAME=$($OBJDUMP -p $$1_FILENAME | grep "SONAME.*$2" | awk '{V=2; print $V}')
- fi
- else
- AC_MSG_CHECKING([for lib$2 dylib])
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch
deleted file mode 100644
index 9f209e8e04..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.002-268d6a0-fix_ASIC_hang.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 268d6a01b6a7dea0d53b042c246c95e87f4fc3d8 Mon Sep 17 00:00:00 2001
-From: xbmc
-Date: Thu, 26 Jul 2012 15:43:24 +0200
-Subject: [PATCH] move deleting gl textures to TextureManager, fixes asic hang
- on AMD
-
----
- xbmc/Application.cpp | 4 ++--
- xbmc/guilib/GUIFontTTFGL.cpp | 3 ++-
- xbmc/guilib/TextureManager.cpp | 13 +++++++++++++
- xbmc/guilib/TextureManager.h | 2 ++
- 4 files changed, 19 insertions(+), 3 deletions(-)
-
-diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
-index 71d8a4e..b66459a 100644
---- a/xbmc/Application.cpp
-+++ b/xbmc/Application.cpp
-@@ -2231,8 +2231,6 @@ void CApplication::Render()
-
- g_Windowing.EndRender();
-
-- g_TextureManager.FreeUnusedTextures();
--
- // reset our info cache - we do this at the end of Render so that it is
- // fresh for the next process(), or after a windowclose animation (where process()
- // isn't called)
-@@ -2270,6 +2268,8 @@ void CApplication::Render()
- }
- CTimeUtils::UpdateFrameTime(flip);
-
-+ g_TextureManager.FreeUnusedTextures();
-+
- g_renderManager.UpdateResolution();
- g_renderManager.ManageCaptures();
- }
-diff --git a/xbmc/guilib/GUIFontTTFGL.cpp b/xbmc/guilib/GUIFontTTFGL.cpp
-index 87e07ca..6c93eb8 100644
---- a/xbmc/guilib/GUIFontTTFGL.cpp
-+++ b/xbmc/guilib/GUIFontTTFGL.cpp
-@@ -24,6 +24,7 @@
- #include "GUIFontTTFGL.h"
- #include "GUIFontManager.h"
- #include "Texture.h"
-+#include "TextureManager.h"
- #include "GraphicContext.h"
- #include "gui3d.h"
- #include "utils/log.h"
-@@ -234,7 +235,7 @@ void CGUIFontTTFGL::DeleteHardwareTexture()
- if (m_bTextureLoaded)
- {
- if (glIsTexture(m_nTexture))
-- glDeleteTextures(1, (GLuint*) &m_nTexture);
-+ g_TextureManager.ReleaseHwTexture(m_nTexture);
- m_bTextureLoaded = false;
- }
- }
-diff --git a/xbmc/guilib/TextureManager.cpp b/xbmc/guilib/TextureManager.cpp
-index 9ef7889..ccd0d03 100644
---- a/xbmc/guilib/TextureManager.cpp
-+++ b/xbmc/guilib/TextureManager.cpp
-@@ -457,6 +457,19 @@ void CGUITextureManager::FreeUnusedTextures()
- for (ivecTextures i = m_unusedTextures.begin(); i != m_unusedTextures.end(); ++i)
- delete *i;
- m_unusedTextures.clear();
-+
-+#if defined(HAS_GL) || defined(HAS_GLES)
-+ for (unsigned int i = 0; i < m_unusedHwTextures.size(); ++i)
-+ {
-+ glDeleteTextures(1, (GLuint*) &m_unusedHwTextures[i]);
-+ }
-+#endif
-+ m_unusedHwTextures.clear();
-+}
-+
-+void CGUITextureManager::ReleaseHwTexture(unsigned int texture)
-+{
-+ m_unusedHwTextures.push_back(texture);
- }
-
- void CGUITextureManager::Cleanup()
-diff --git a/xbmc/guilib/TextureManager.h b/xbmc/guilib/TextureManager.h
-index dd47f48..001f470 100644
---- a/xbmc/guilib/TextureManager.h
-+++ b/xbmc/guilib/TextureManager.h
-@@ -124,9 +124,11 @@ class CGUITextureManager
- void RemoveTexturePath(const CStdString &texturePath); ///< Remove a path from the paths to check when loading media
-
- void FreeUnusedTextures(); ///< Free textures (called from app thread only)
-+ void ReleaseHwTexture(unsigned int texture);
- protected:
- std::vector m_vecTextures;
- std::vector m_unusedTextures;
-+ std::vector m_unusedHwTextures;
- typedef std::vector::iterator ivecTextures;
- // we have 2 texture bundles (one for the base textures, one for the theme)
- CTextureBundle m_TexBundle[2];
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.003-rar-PR1147.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.003-rar-PR1147.patch
deleted file mode 100644
index a6a73bf20c..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.003-rar-PR1147.patch
+++ /dev/null
@@ -1,148 +0,0 @@
-From f01f95af95f287847c850572abe16b6969967ba7 Mon Sep 17 00:00:00 2001
-From: Anssi Hannula
-Date: Wed, 16 May 2012 19:01:17 +0300
-Subject: [PATCH 1/3] fixed: crashes with corrupted rar files
-
-UnrarXLib does not handle invalid files gracefully enough, and some
-files can cause it to tell CRarFile that it has written more data into
-its buffer than actually fits there, causing CRarFile::Read() to
-eventually overread the buffer.
-
-Add checks in CRarFile for the validity of byte counts retrieved from
-UnrarXLib to prevent crashes in such situations.
-(cherry picked from commit ca9457286994ef0b021744797b8d78fb78260436)
----
- xbmc/filesystem/FileRar.cpp | 17 +++++++++++++++++
- 1 file changed, 17 insertions(+)
-
-diff --git a/xbmc/filesystem/FileRar.cpp b/xbmc/filesystem/FileRar.cpp
-index 9c87a35..d026f8f 100644
---- a/xbmc/filesystem/FileRar.cpp
-+++ b/xbmc/filesystem/FileRar.cpp
-@@ -310,6 +310,14 @@ unsigned int CFileRar::Read(void *lpBuf, int64_t uiBufSize)
-
- m_iDataInBuffer = MAXWINMEMSIZE-m_pExtract->GetDataIO().UnpackToMemorySize;
-
-+ if (m_iDataInBuffer < 0 ||
-+ m_iDataInBuffer > MAXWINMEMSIZE - (m_szStartOfBuffer - m_szBuffer))
-+ {
-+ // invalid data returned by UnrarXLib, prevent a crash
-+ CLog::Log(LOGERROR, "CRarFile::Read - Data buffer in inconsistent state");
-+ m_iDataInBuffer = 0;
-+ }
-+
- if (m_iDataInBuffer == 0)
- break;
-
-@@ -471,6 +479,15 @@ int64_t CFileRar::Seek(int64_t iFilePosition, int iWhence)
- }
- m_iDataInBuffer = m_pExtract->GetDataIO().m_iSeekTo; // keep data
- m_iBufferStart = m_pExtract->GetDataIO().m_iStartOfBuffer;
-+
-+ if (m_iDataInBuffer < 0 || m_iDataInBuffer > MAXWINMEMSIZE)
-+ {
-+ // invalid data returned by UnrarXLib, prevent a crash
-+ CLog::Log(LOGERROR, "CRarFile::Seek - Data buffer in inconsistent state");
-+ m_iDataInBuffer = 0;
-+ return -1;
-+ }
-+
- m_szStartOfBuffer = m_szBuffer+MAXWINMEMSIZE-m_iDataInBuffer;
- m_iFilePosition = iFilePosition;
-
---
-1.7.10
-
-
-From de1be4534cf410896b3102f95b6e02019ed64a90 Mon Sep 17 00:00:00 2001
-From: Anssi Hannula
-Date: Wed, 16 May 2012 17:13:07 +0300
-Subject: [PATCH 2/3] fixed: rars that have unpacked size stored on first
- volume only
-
-Some multi-volume RAR files have their unpacked size set as 0 in all
-volumes except the first one.
-
-Use the previous unpacked size instead of 0 in such cases in order to
-support such files properly.
-(cherry picked from commit 683457d27736c09415a11d80933553f75139a253)
----
- lib/UnrarXLib/volume.cpp | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/lib/UnrarXLib/volume.cpp b/lib/UnrarXLib/volume.cpp
-index 1f4d5e3..b24e98b 100644
---- a/lib/UnrarXLib/volume.cpp
-+++ b/lib/UnrarXLib/volume.cpp
-@@ -15,6 +15,7 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
- Log(Arc.FileName,St(MDataBadCRC),hd->FileName,Arc.FileName);
- }
-
-+ Int64 PrevFullUnpSize = hd->FullUnpSize;
- Int64 PosBeforeClose=Arc.Tell();
- Arc.Close();
-
-@@ -144,6 +145,13 @@ bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Comman
- }
- }
- #endif
-+
-+ if (hd->FullUnpSize == 0)
-+ {
-+ // some archives only have correct UnpSize in the first volume
-+ hd->FullUnpSize = PrevFullUnpSize;
-+ }
-+
- if (DataIO!=NULL)
- {
- if (HeaderType==ENDARC_HEAD)
---
-1.7.10
-
-
-From d7bed5ddbbc98d7fedac663410d8e7e64bdf20c7 Mon Sep 17 00:00:00 2001
-From: Anssi Hannula
-Date: Wed, 16 May 2012 00:14:49 +0300
-Subject: [PATCH 3/3] fixed: CRarFile::Read() returning wrong data after some
- seek patterns
-
-Certain seek patterns on a file inside a non-compressed rar file can
-cause CmdExtract::UnstoreFile() to think that the destination buffer has
-been filled (as DestUnpSize counter, originally set to the file size,
-reaches zero).
-
-However, counting written bytes using DestUnpSize doesn't make sense for
-the UnpackToMemory codepath used for non-compressed rar files, as there
-can be seeks which can eventually cause more data to be read than what
-the actual file size was. The actual output buffer is internally handled
-by ComprDataIO.
-
-The check in UnstoreFile() will result in not all data being written to
-the destination buffer, causing CRarFile::Read() to return old stale
-data.
-
-Fix that by dropping the unnecessary DestUnpSize handling in
-UnpackToMemory codepath of CmdExtract::UnstoreFile().
-(cherry picked from commit 840cd4ce4ac8c781e7d35db2ed86d575a42c37e7)
----
- lib/UnrarXLib/extract.cpp | 3 ---
- 1 file changed, 3 deletions(-)
-
-diff --git a/lib/UnrarXLib/extract.cpp b/lib/UnrarXLib/extract.cpp
-index b4a8091..368a899 100644
---- a/lib/UnrarXLib/extract.cpp
-+++ b/lib/UnrarXLib/extract.cpp
-@@ -863,10 +863,7 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize)
- }
- if (Code > 0)
- {
-- Code=Code=0)
-- DestUnpSize-=Code;
- }
- else
- {
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.011-airtunes_reapply_lost_fix.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.011-airtunes_reapply_lost_fix.patch
deleted file mode 100644
index 4885fe33e9..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.011-airtunes_reapply_lost_fix.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From ab175ba28508445f6aff57386a8ce04b58a86f60 Mon Sep 17 00:00:00 2001
-From: Memphiz
-Date: Fri, 11 May 2012 19:56:37 +0200
-Subject: [PATCH] [fix] - reapply fix for airtunes with AE which was lost
- during merge
-
----
- xbmc/network/AirTunesServer.cpp | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp
-index 285a0a6..a60ad09 100644
---- a/xbmc/network/AirTunesServer.cpp
-+++ b/xbmc/network/AirTunesServer.cpp
-@@ -125,11 +125,11 @@ ao_device* CAirTunesServer::AudioOutputFunctions::ao_open_live(int driver_id, ao
- if (ao_get_option(option, "name"))
- item.GetMusicInfoTag()->SetTitle(ao_get_option(option, "name"));
-
-- g_application.getApplicationMessenger().PlayFile(item);
--
- ThreadMessage tMsg2 = { TMSG_GUI_ACTIVATE_WINDOW, WINDOW_VISUALISATION, 0 };
- g_application.getApplicationMessenger().SendMessage(tMsg2, true);
-
-+ g_application.getApplicationMessenger().PlayFile(item);
-+
- return (ao_device*) device;
- }
-
---
-1.7.10
-
diff --git a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch b/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch
deleted file mode 100644
index 9ea05b6281..0000000000
--- a/packages/mediacenter/xbmc/patches/xbmc-11.0.2-999.012-airtunes_implementation_for_windows_using_libshairplay.patch
+++ /dev/null
@@ -1,527 +0,0 @@
-From b73018af2ae69c7cfad0a4461d169a49c7d0dfbf Mon Sep 17 00:00:00 2001
-From: Memphiz
-Date: Tue, 15 May 2012 19:12:07 +0200
-Subject: [PATCH] [airtunes] - implementation for windows using libshairplay
-
----
- xbmc/network/AirTunesServer.cpp | 330 +++++++++++++++++++++++++++++++++++++--
- xbmc/network/AirTunesServer.h | 23 +++
- 2 files changed, 343 insertions(+), 10 deletions(-)
-
-diff --git a/xbmc/network/AirTunesServer.cpp b/xbmc/network/AirTunesServer.cpp
-index a60ad09..e14da90 100644
---- a/xbmc/network/AirTunesServer.cpp
-+++ b/xbmc/network/AirTunesServer.cpp
-@@ -17,7 +17,9 @@
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-+#if !defined(TARGET_WINDOWS)
- #pragma GCC diagnostic ignored "-Wwrite-strings"
-+#endif
-
- #include "AirTunesServer.h"
-
-@@ -37,15 +39,243 @@
- #include "music/tags/MusicInfoTag.h"
- #include "FileItem.h"
- #include "GUIInfoManager.h"
-+#include "guilib/GUIWindowManager.h"
- #include "utils/Variant.h"
- #include "settings/AdvancedSettings.h"
-+#include "utils/EndianSwap.h"
-+
-+#include