summaryrefslogtreecommitdiff
path: root/media-tv/xbmc/files
diff options
context:
space:
mode:
Diffstat (limited to 'media-tv/xbmc/files')
-rw-r--r--media-tv/xbmc/files/xbmc-10.0-python-2.7.patch768
-rw-r--r--media-tv/xbmc/files/xbmc-10.1-gcc-4.6.patch100
-rw-r--r--media-tv/xbmc/files/xbmc-10.1-headers.patch10
-rw-r--r--media-tv/xbmc/files/xbmc-10.1-libpng-1.5.patch596
-rw-r--r--media-tv/xbmc/files/xbmc-11.0-libpng-1.5.patch605
-rw-r--r--media-tv/xbmc/files/xbmc-11.0-no-exec-stack.patch30
-rw-r--r--media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-fix-plt-trn-get.patch51
-rw-r--r--media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-headers.patch12
-rw-r--r--media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5.patch596
-rw-r--r--media-tv/xbmc/files/xbmc-9.11-TexturePacker-parallel-build.patch13
-rw-r--r--media-tv/xbmc/files/xbmc-9.11-jpeg-speedup.patch18
-rw-r--r--media-tv/xbmc/files/xbmc-9.11-libpng14.patch92
-rw-r--r--media-tv/xbmc/files/xbmc-9.11-shader-upscalers.patch887
-rw-r--r--media-tv/xbmc/files/xbmc-9.11-use-cdio-system-headers-on-non-win32.patch129
-rw-r--r--media-tv/xbmc/files/xbmc-9.11-wavpack.patch44
-rw-r--r--media-tv/xbmc/files/xbmc-9999-arm-kill-softfp.patch15
-rw-r--r--media-tv/xbmc/files/xbmc-9999-libpng-1.5-fix-plt-trn-get.patch47
-rw-r--r--media-tv/xbmc/files/xbmc-9999-no-arm-flags.patch16
-rw-r--r--media-tv/xbmc/files/xbmc-9999-no-exec-stack.patch28
-rw-r--r--media-tv/xbmc/files/xbmc-9999-nomythtv.patch206
20 files changed, 4263 insertions, 0 deletions
diff --git a/media-tv/xbmc/files/xbmc-10.0-python-2.7.patch b/media-tv/xbmc/files/xbmc-10.0-python-2.7.patch
new file mode 100644
index 00000000..e3d17a5e
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-10.0-python-2.7.patch
@@ -0,0 +1,768 @@
+patch from upstream
+
+https://bugs.gentoo.org/350098
+
+From ab0f816c6307f38d7248d0469379c981f94b816d Mon Sep 17 00:00:00 2001
+From: ceros7 <ceros7@568bbfeb-2a22-0410-94d2-cc84cf5bfa90>
+Date: Mon, 30 Aug 2010 16:46:50 +0000
+Subject: [PATCH] Support external python2.7.
+
+git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/python2.7@33342 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
+---
+ configure.in | 10 ++++++-
+ xbmc/lib/libPython/XBPyThread.cpp | 5 +++-
+ xbmc/lib/libPython/XBPyThread.h | 4 ++-
+ xbmc/lib/libPython/XBPython.cpp | 24 +++++++++++++++-----
+ xbmc/lib/libPython/XBPythonDll.cpp | 4 ++-
+ xbmc/lib/libPython/XBPythonDllFuncs.S | 4 ++-
+ xbmc/lib/libPython/linux/Makefile.in | 5 +++-
+ xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/PythonAddon.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/PythonPlayer.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/action.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/control.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlbutton.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlcheckmark.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlfadelabel.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlgroup.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlimage.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controllabel.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controllist.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlprogress.cpp | 4 ++-
+ .../libPython/xbmcmodule/controlradiobutton.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlslider.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controlspin.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/controltextbox.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/dialog.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/dialog.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/infotagmusic.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/infotagvideo.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/keyboard.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/listitem.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/listitem.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/player.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/pyplaylist.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/pyplaylist.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/pyutil.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/window.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/winxml.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/winxml.h | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/winxmldialog.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/xbmcaddonmodule.cpp | 4 ++-
+ xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp | 5 +++-
+ xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp | 4 ++-
+ 42 files changed, 149 insertions(+), 48 deletions(-)
+
+diff --git a/configure.in b/configure.in
+index 4c0b1b7..cd3429e 100644
+--- a/configure.in
++++ b/configure.in
+@@ -901,7 +901,11 @@ fi
+
+ # External Python
+ if test "$use_external_python" = "yes"; then
+- AC_CHECK_LIB([python2.6], [main],
++ AC_CHECK_LIB([python2.7], [main],
++ [AC_DEFINE([HAVE_LIBPYTHON2_7], [1],
++ [Define to 1 if you have the 'python2.7' library.])
++ USE_PYTHON2_7=1],
++ [AC_CHECK_LIB([python2.6], [main],
+ [AC_DEFINE([HAVE_LIBPYTHON2_6], [1],
+ [Define to 1 if you have the 'python2.6' library.])
+ USE_PYTHON2_6=1],
+@@ -913,9 +917,10 @@ if test "$use_external_python" = "yes"; then
+ [AC_DEFINE([HAVE_LIBPYTHON2_4], [1],
+ [Define to 1 if you have the 'python2.4' library.])
+ USE_PYTHON2_4=1],
+- [AC_MSG_ERROR($missing_library)] )] )] )
++ [AC_MSG_ERROR($missing_library)] )] )] )] )
+
+ AC_MSG_NOTICE($external_python_enabled)
++ test "$USE_PYTHON2_7" && AC_MSG_NOTICE([Using Python 2.7])
+ test "$USE_PYTHON2_6" && AC_MSG_NOTICE([Using Python 2.6])
+ test "$USE_PYTHON2_5" && AC_MSG_NOTICE([Using Python 2.5])
+ test "$USE_PYTHON2_4" && AC_MSG_NOTICE([Using Python 2.4])
+@@ -1471,6 +1476,7 @@ AC_SUBST(USE_INTERNAL_LIBDTS)
+ AC_SUBST(USE_EXTERNAL_LIBMPEG2)
+ AC_SUBST(USE_EXTERNAL_LIBWAVPACK)
+ AC_SUBST(USE_EXTERNAL_PYTHON)
++AC_SUBST(USE_PYTHON2_7)
+ AC_SUBST(USE_PYTHON2_6)
+ AC_SUBST(USE_PYTHON2_5)
+ AC_SUBST(USE_PYTHON2_4)
+diff --git a/xbmc/lib/libPython/XBPyThread.cpp b/xbmc/lib/libPython/XBPyThread.cpp
+index 3a6f34e..71b4b9a 100644
+--- a/xbmc/lib/libPython/XBPyThread.cpp
++++ b/xbmc/lib/libPython/XBPyThread.cpp
+@@ -24,7 +24,10 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #include <python2.7/osdefs.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #include <python2.6/osdefs.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+diff --git a/xbmc/lib/libPython/XBPyThread.h b/xbmc/lib/libPython/XBPyThread.h
+index c3da337..eea7fea 100644
+--- a/xbmc/lib/libPython/XBPyThread.h
++++ b/xbmc/lib/libPython/XBPyThread.h
+@@ -26,7 +26,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/XBPython.cpp b/xbmc/lib/libPython/XBPython.cpp
+index e52cdfb..defcf14 100644
+--- a/xbmc/lib/libPython/XBPython.cpp
++++ b/xbmc/lib/libPython/XBPython.cpp
+@@ -24,7 +24,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+@@ -61,7 +63,9 @@ XBPython g_pythonParser;
+ #define PYTHON_DLL "special://xbmcbin/system/python/python24-x86-osx.so"
+ #endif
+ #elif defined(__x86_64__)
+-#if (defined HAVE_LIBPYTHON2_6)
++#if (defined HAVE_LIBPYTHON2_7)
++#define PYTHON_DLL "special://xbmcbin/system/python/python27-x86_64-linux.so"
++#elif (defined HAVE_LIBPYTHON2_6)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python26-x86_64-linux.so"
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python25-x86_64-linux.so"
+@@ -69,7 +73,9 @@ XBPython g_pythonParser;
+ #define PYTHON_DLL "special://xbmcbin/system/python/python24-x86_64-linux.so"
+ #endif
+ #elif defined(_POWERPC)
+-#if (defined HAVE_LIBPYTHON2_6)
++#if (defined HAVE_LIBPYTHON2_7)
++#define PYTHON_DLL "special://xbmcbin/system/python/python27-powerpc-linux.so"
++#elif (defined HAVE_LIBPYTHON2_6)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python26-powerpc-linux.so"
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python25-powerpc-linux.so"
+@@ -77,7 +83,9 @@ XBPython g_pythonParser;
+ #define PYTHON_DLL "special://xbmcbin/system/python/python24-powerpc-linux.so"
+ #endif
+ #elif defined(_POWERPC64)
+-#if (defined HAVE_LIBPYTHON2_6)
++#if (defined HAVE_LIBPYTHON2_7)
++#define PYTHON_DLL "special://xbmcbin/system/python/python27-powerpc64-linux.so"
++#elif (defined HAVE_LIBPYTHON2_6)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python26-powerpc64-linux.so"
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python25-powerpc64-linux.so"
+@@ -85,7 +93,9 @@ XBPython g_pythonParser;
+ #define PYTHON_DLL "special://xbmcbin/system/python/python24-powerpc64-linux.so"
+ #endif
+ #elif defined(_ARMEL)
+-#if (defined HAVE_LIBPYTHON2_6)
++#if (defined HAVE_LIBPYTHON2_7)
++#define PYTHON_DLL "special://xbmc/system/python/python27-arm.so"
++#elif (defined HAVE_LIBPYTHON2_6)
+ #define PYTHON_DLL "special://xbmc/system/python/python26-arm.so"
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #define PYTHON_DLL "special://xbmc/system/python/python25-arm.so"
+@@ -93,7 +103,9 @@ XBPython g_pythonParser;
+ #define PYTHON_DLL "special://xbmc/system/python/python24-arm.so"
+ #endif
+ #else /* !__x86_64__ && !__powerpc__ */
+-#if (defined HAVE_LIBPYTHON2_6)
++#if (defined HAVE_LIBPYTHON2_7)
++#define PYTHON_DLL "special://xbmcbin/system/python/python27-i486-linux.so"
++#elif (defined HAVE_LIBPYTHON2_6)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python26-i486-linux.so"
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #define PYTHON_DLL "special://xbmcbin/system/python/python25-i486-linux.so"
+diff --git a/xbmc/lib/libPython/XBPythonDll.cpp b/xbmc/lib/libPython/XBPythonDll.cpp
+index bc9d827..87ac7d7 100644
+--- a/xbmc/lib/libPython/XBPythonDll.cpp
++++ b/xbmc/lib/libPython/XBPythonDll.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/pyconfig.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/pyconfig.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/pyconfig.h>
+diff --git a/xbmc/lib/libPython/XBPythonDllFuncs.S b/xbmc/lib/libPython/XBPythonDllFuncs.S
+index 6b7a6c3..f59b192 100644
+--- a/xbmc/lib/libPython/XBPythonDllFuncs.S
++++ b/xbmc/lib/libPython/XBPythonDllFuncs.S
+@@ -2,7 +2,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/pyconfig.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/pyconfig.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/pyconfig.h>
+diff --git a/xbmc/lib/libPython/linux/Makefile.in b/xbmc/lib/libPython/linux/Makefile.in
+index 7011434..0786937 100644
+--- a/xbmc/lib/libPython/linux/Makefile.in
++++ b/xbmc/lib/libPython/linux/Makefile.in
+@@ -5,7 +5,10 @@ LDFLAGS=@LDFLAGS@
+ SHELL=/bin/bash
+ SYSDIR=../../../../system/python
+
+-ifeq (@USE_PYTHON2_6@,1)
++ifeq (@USE_PYTHON2_7@,1)
++ PYVERSION=python2.7
++ SO=python27-$(ARCH).so
++else ifeq (@USE_PYTHON2_6@,1)
+ PYVERSION=python2.6
+ SO=python26-$(ARCH).so
+ else ifeq (@USE_PYTHON2_5@,1)
+diff --git a/xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.h b/xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.h
+index 620d9bd..06fa146 100644
+--- a/xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.h
++++ b/xbmc/lib/libPython/xbmcmodule/GUIPythonWindow.h
+@@ -26,7 +26,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/PythonAddon.h b/xbmc/lib/libPython/xbmcmodule/PythonAddon.h
+index ec7ed28..41eb8ea 100644
+--- a/xbmc/lib/libPython/xbmcmodule/PythonAddon.h
++++ b/xbmc/lib/libPython/xbmcmodule/PythonAddon.h
+@@ -25,7 +25,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/PythonPlayer.h b/xbmc/lib/libPython/xbmcmodule/PythonPlayer.h
+index ecee993..24a1c87 100644
+--- a/xbmc/lib/libPython/xbmcmodule/PythonPlayer.h
++++ b/xbmc/lib/libPython/xbmcmodule/PythonPlayer.h
+@@ -25,7 +25,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/action.h b/xbmc/lib/libPython/xbmcmodule/action.h
+index 0e20000..7f8b1bc 100644
+--- a/xbmc/lib/libPython/xbmcmodule/action.h
++++ b/xbmc/lib/libPython/xbmcmodule/action.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/control.h b/xbmc/lib/libPython/xbmcmodule/control.h
+index c76b37c..a9ec63d 100644
+--- a/xbmc/lib/libPython/xbmcmodule/control.h
++++ b/xbmc/lib/libPython/xbmcmodule/control.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlbutton.cpp b/xbmc/lib/libPython/xbmcmodule/controlbutton.cpp
+index b24ccce..7455ca7 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlbutton.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlbutton.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlcheckmark.cpp b/xbmc/lib/libPython/xbmcmodule/controlcheckmark.cpp
+index 96e4743..86a7d8b 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlcheckmark.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlcheckmark.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlfadelabel.cpp b/xbmc/lib/libPython/xbmcmodule/controlfadelabel.cpp
+index 68442d8..c6eb052 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlfadelabel.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlfadelabel.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlgroup.cpp b/xbmc/lib/libPython/xbmcmodule/controlgroup.cpp
+index aadfc17..8275324 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlgroup.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlgroup.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlimage.cpp b/xbmc/lib/libPython/xbmcmodule/controlimage.cpp
+index 79835d6..f106e90 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlimage.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlimage.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controllabel.cpp b/xbmc/lib/libPython/xbmcmodule/controllabel.cpp
+index aca22e4..38a9c07 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controllabel.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controllabel.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controllist.cpp b/xbmc/lib/libPython/xbmcmodule/controllist.cpp
+index 0c67b5c..bb57776 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controllist.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controllist.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlprogress.cpp b/xbmc/lib/libPython/xbmcmodule/controlprogress.cpp
+index a21e462..b460a2a 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlprogress.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlprogress.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlradiobutton.cpp b/xbmc/lib/libPython/xbmcmodule/controlradiobutton.cpp
+index ec54efd..b966a17 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlradiobutton.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlradiobutton.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlslider.cpp b/xbmc/lib/libPython/xbmcmodule/controlslider.cpp
+index 21ea5e7..c5f65b3 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlslider.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlslider.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controlspin.cpp b/xbmc/lib/libPython/xbmcmodule/controlspin.cpp
+index 4e24e14..feead3c 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controlspin.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controlspin.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/controltextbox.cpp b/xbmc/lib/libPython/xbmcmodule/controltextbox.cpp
+index b4c44d5..4a7c688 100644
+--- a/xbmc/lib/libPython/xbmcmodule/controltextbox.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/controltextbox.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/dialog.cpp b/xbmc/lib/libPython/xbmcmodule/dialog.cpp
+index caa8986..cffe485 100644
+--- a/xbmc/lib/libPython/xbmcmodule/dialog.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/dialog.cpp
+@@ -24,7 +24,9 @@
+ #endif
+ #include "dialog.h"
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/dialog.h b/xbmc/lib/libPython/xbmcmodule/dialog.h
+index edcae41..a61c4b1 100644
+--- a/xbmc/lib/libPython/xbmcmodule/dialog.h
++++ b/xbmc/lib/libPython/xbmcmodule/dialog.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/infotagmusic.h b/xbmc/lib/libPython/xbmcmodule/infotagmusic.h
+index d202e48..590b858 100644
+--- a/xbmc/lib/libPython/xbmcmodule/infotagmusic.h
++++ b/xbmc/lib/libPython/xbmcmodule/infotagmusic.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/infotagvideo.h b/xbmc/lib/libPython/xbmcmodule/infotagvideo.h
+index f2bb300..e808573 100644
+--- a/xbmc/lib/libPython/xbmcmodule/infotagvideo.h
++++ b/xbmc/lib/libPython/xbmcmodule/infotagvideo.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/keyboard.h b/xbmc/lib/libPython/xbmcmodule/keyboard.h
+index e5c817f..0f069e3 100644
+--- a/xbmc/lib/libPython/xbmcmodule/keyboard.h
++++ b/xbmc/lib/libPython/xbmcmodule/keyboard.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/listitem.cpp b/xbmc/lib/libPython/xbmcmodule/listitem.cpp
+index 137436e..20105ef 100644
+--- a/xbmc/lib/libPython/xbmcmodule/listitem.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/listitem.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/listitem.h b/xbmc/lib/libPython/xbmcmodule/listitem.h
+index 7ebcd6c..3d4a6c8 100644
+--- a/xbmc/lib/libPython/xbmcmodule/listitem.h
++++ b/xbmc/lib/libPython/xbmcmodule/listitem.h
+@@ -25,7 +25,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/player.h b/xbmc/lib/libPython/xbmcmodule/player.h
+index 48dc9c7..34a102d 100644
+--- a/xbmc/lib/libPython/xbmcmodule/player.h
++++ b/xbmc/lib/libPython/xbmcmodule/player.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/pyplaylist.cpp b/xbmc/lib/libPython/xbmcmodule/pyplaylist.cpp
+index c7e7f62..6df8548 100644
+--- a/xbmc/lib/libPython/xbmcmodule/pyplaylist.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/pyplaylist.cpp
+@@ -26,7 +26,9 @@
+ #include "Util.h"
+ #include "pyplaylist.h"
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/pyplaylist.h b/xbmc/lib/libPython/xbmcmodule/pyplaylist.h
+index f2334bb..2410314 100644
+--- a/xbmc/lib/libPython/xbmcmodule/pyplaylist.h
++++ b/xbmc/lib/libPython/xbmcmodule/pyplaylist.h
+@@ -25,7 +25,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/pyutil.h b/xbmc/lib/libPython/xbmcmodule/pyutil.h
+index 4acf6e5..1a156f8 100644
+--- a/xbmc/lib/libPython/xbmcmodule/pyutil.h
++++ b/xbmc/lib/libPython/xbmcmodule/pyutil.h
+@@ -25,7 +25,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/window.h b/xbmc/lib/libPython/xbmcmodule/window.h
+index 6ce8e72..40304ff 100644
+--- a/xbmc/lib/libPython/xbmcmodule/window.h
++++ b/xbmc/lib/libPython/xbmcmodule/window.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/winxml.cpp b/xbmc/lib/libPython/xbmcmodule/winxml.cpp
+index d3b703f..3e1b3c8 100644
+--- a/xbmc/lib/libPython/xbmcmodule/winxml.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/winxml.cpp
+@@ -24,7 +24,9 @@
+ #endif
+ #include "winxml.h"
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/winxml.h b/xbmc/lib/libPython/xbmcmodule/winxml.h
+index 6e6489e..f3a8dd8 100644
+--- a/xbmc/lib/libPython/xbmcmodule/winxml.h
++++ b/xbmc/lib/libPython/xbmcmodule/winxml.h
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/winxmldialog.cpp b/xbmc/lib/libPython/xbmcmodule/winxmldialog.cpp
+index b021501..92d9903 100644
+--- a/xbmc/lib/libPython/xbmcmodule/winxmldialog.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/winxmldialog.cpp
+@@ -24,7 +24,9 @@
+ #endif
+ #include "winxml.h"
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/xbmcaddonmodule.cpp b/xbmc/lib/libPython/xbmcmodule/xbmcaddonmodule.cpp
+index b8bc0a3..c65aded 100644
+--- a/xbmc/lib/libPython/xbmcmodule/xbmcaddonmodule.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/xbmcaddonmodule.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+diff --git a/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp b/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp
+index 87c0ead..9941769 100644
+--- a/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/xbmcguimodule.cpp
+@@ -23,7 +23,10 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #include <python2.7/structmember.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #include <python2.6/structmember.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+diff --git a/xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp b/xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp
+index 3bab5a9..1e2c480 100644
+--- a/xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp
++++ b/xbmc/lib/libPython/xbmcmodule/xbmcmodule.cpp
+@@ -23,7 +23,9 @@
+ #include "config.h"
+ #endif
+ #if (defined USE_EXTERNAL_PYTHON)
+- #if (defined HAVE_LIBPYTHON2_6)
++ #if (defined HAVE_LIBPYTHON2_7)
++ #include <python2.7/Python.h>
++ #elif (defined HAVE_LIBPYTHON2_6)
+ #include <python2.6/Python.h>
+ #elif (defined HAVE_LIBPYTHON2_5)
+ #include <python2.5/Python.h>
+--
+1.7.3.1
+
diff --git a/media-tv/xbmc/files/xbmc-10.1-gcc-4.6.patch b/media-tv/xbmc/files/xbmc-10.1-gcc-4.6.patch
new file mode 100644
index 00000000..b3e8c7c2
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-10.1-gcc-4.6.patch
@@ -0,0 +1,100 @@
+http://trac.xbmc.org/ticket/11383
+http://bugs.gentoo.org/367261
+
+From c66099c4d8e6b2d748ca3ddc31ee90b731d0f620 Mon Sep 17 00:00:00 2001
+From: Stephan Raue <stephan@openelec.tv>
+Date: Wed, 30 Mar 2011 14:57:28 +0200
+Subject: [PATCH] dvdplayer: fix build with gcc-4.6. Flags to the Linker must be passed via -Wl,. This fixes ticket #11383
+
+Signed-off-by: Stephan Raue <stephan@openelec.tv>
+---
+ xbmc/cores/dvdplayer/Codecs/Makefile.in | 18 +++++++++---------
+ xbmc/cores/dvdplayer/Codecs/libdvd/Makefile.in | 4 ++--
+ 2 files changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/xbmc/cores/dvdplayer/Codecs/Makefile.in b/xbmc/cores/dvdplayer/Codecs/Makefile.in
+index a7ef1a0..308664a 100644
+--- a/xbmc/cores/dvdplayer/Codecs/Makefile.in
++++ b/xbmc/cores/dvdplayer/Codecs/Makefile.in
+@@ -148,32 +148,32 @@ liba52:
+ else
+
+ $(SYSDIR)/avutil-50-$(ARCH).so: ffmpeg/libavutil/libavutil.so
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ -Wl,-Bsymbolic \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ -Wl,-Bsymbolic \
+ ffmpeg/libavutil/*.o `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ $(SYSDIR)/avcodec-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavcodec/libavcodec.so
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ -Wl,-Bsymbolic \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ -Wl,-Bsymbolic \
+ ffmpeg/libavcodec/*.o ffmpeg/libavcodec/$(ARCH_DIR)/*.o \
+ `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ $(SYSDIR)/avformat-52-$(ARCH).so: $(WRAPPER) ffmpeg/libavformat/libavformat.so
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ -Wl,-Bsymbolic \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ -Wl,-Bsymbolic \
+ ffmpeg/libavformat/*.o `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ ifneq ($(ARCH), arm)
+ $(SYSDIR)/swscale-0.6.1-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.so
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ -Wl,-Bsymbolic \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ -Wl,-Bsymbolic \
+ ffmpeg/libswscale/*.o ffmpeg/libswscale/$(ARCH_DIR)/*.o \
+ `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+ else # No ARM version of swscale available yet.
+ $(SYSDIR)/swscale-0.6.1-$(ARCH).so: $(WRAPPER) ffmpeg/libswscale/libswscale.so
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ -Wl,-Bsymbolic \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ -Wl,-Bsymbolic \
+ ffmpeg/libswscale/*.o \
+ `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+ endif
+
+ $(SYSDIR)/postproc-51-$(ARCH).so: $(WRAPPER) ffmpeg/libpostproc/libpostproc.so
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ -Wl,-Bsymbolic \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ -Wl,-Bsymbolic \
+ ffmpeg/libpostproc/*.o `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ ffmpeg/libavutil/libavutil.so : ffmpeg;
+@@ -185,17 +185,17 @@ ffmpeg:
+ $(MAKE) -C $@
+
+ $(SYSDIR)/libdts-$(ARCH).so: $(WRAPPER) libdts/libdts/libdts.a
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ \
+ libdts/libdts/bitstream.o \
+ libdts/libdts/downmix.o libdts/libdts/parse.o \
+ `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ $(SYSDIR)/liba52-$(ARCH).so: $(WRAPPER) liba52/liba52/liba52.la
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ liba52/liba52/.libs/*.o \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ liba52/liba52/.libs/*.o \
+ -Wl`cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ $(SYSDIR)/libao-$(ARCH).so: $(WRAPPER) liba52/libao/libao.a
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ liba52/libao/libao.a \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ liba52/libao/libao.a \
+ -Wl`cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ libdts/libdts/libdts.a : libdts;
+diff --git a/xbmc/cores/dvdplayer/Codecs/libdvd/Makefile.in b/xbmc/cores/dvdplayer/Codecs/libdvd/Makefile.in
+index 3c487e9..6d4abd4 100644
+--- a/xbmc/cores/dvdplayer/Codecs/libdvd/Makefile.in
++++ b/xbmc/cores/dvdplayer/Codecs/libdvd/Makefile.in
+@@ -49,12 +49,12 @@ $(SYSDIR)/libdvdnav-$(ARCH).so: $(WRAPPER_OSX) $(DVDCSS_A) libdvdread/obj/libdvd
+ else
+
+ $(SYSDIR)/libdvdcss-$(ARCH).so: $(WRAPPER) libdvdcss/src/.libs/libdvdcss.a
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ \
+ libdvdcss/src/*.o \
+ `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ $(SYSDIR)/libdvdnav-$(ARCH).so: $(WRAPPER) $(DVDCSS_A) libdvdread/obj/libdvdread.a libdvdnav/obj/libdvdnav.a
+- $(CC) -o $@ $(LDFLAGS) --soname,$@ $(DVDCSS_O) libdvdread/obj/*.o libdvdnav/obj/*.o \
++ $(CC) -o $@ $(LDFLAGS) -Wl,--soname,$@ $(DVDCSS_O) libdvdread/obj/*.o libdvdnav/obj/*.o \
+ `cat $(WRAPPER:.o=.def)` $(WRAPPER)
+
+ endif
+--
+1.7.0.2
+
diff --git a/media-tv/xbmc/files/xbmc-10.1-headers.patch b/media-tv/xbmc/files/xbmc-10.1-headers.patch
new file mode 100644
index 00000000..8c23db86
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-10.1-headers.patch
@@ -0,0 +1,10 @@
+--- a/tools/TexturePacker/XBTFWriter.cpp
++++ b/tools/TexturePacker/XBTFWriter.cpp
+@@ -28,6 +28,7 @@
+ #include "EndianSwap.h"
+ #define __STDC_FORMAT_MACROS
+ #include <inttypes.h>
++#include <unistd.h> /* for unlink() prototype */
+
+ #define TEMP_FILE "temp.xbt"
+ #define TEMP_SIZE (10*1024*1024)
diff --git a/media-tv/xbmc/files/xbmc-10.1-libpng-1.5.patch b/media-tv/xbmc/files/xbmc-10.1-libpng-1.5.patch
new file mode 100644
index 00000000..4d992275
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-10.1-libpng-1.5.patch
@@ -0,0 +1,596 @@
+fix building with newer libpng. patch by Ian Stakenvicius.
+
+https://bugs.gentoo.org/380127
+
+--- a/xbmc/lib/cximage-6.0/CxImage/ximapng.h
++++ b/xbmc/lib/cximage-6.0/CxImage/ximapng.h
+@@ -69,8 +69,13 @@
+
+ static void PNGAPI user_error_fn(png_structp png_ptr,png_const_charp error_msg)
+ {
++#if PNG_LIBPNG_VER > 10399
++ strncpy((char*)png_get_error_ptr(png_ptr),error_msg,255);
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ strncpy((char*)png_ptr->error_ptr,error_msg,255);
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+ };
+
+--- a/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp
++++ b/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp
+@@ -15,7 +15,11 @@
+ void CxImagePNG::ima_png_error(png_struct *png_ptr, char *message)
+ {
+ strcpy(info.szLastError,message);
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+ ////////////////////////////////////////////////////////////////////////////////
+ #if CXIMAGE_SUPPORT_DECODE
+@@ -62,7 +66,11 @@
+ /* Set error handling if you are using the setjmp/longjmp method (this is
+ * the normal method of doing things with libpng). REQUIRED unless you
+ * set up your own error handlers in the png_create_read_struct() earlier. */
++#if PNG_LIBPNG_VER > 10399
++ if (setjmp(png_jmpbuf(png_ptr))) {
++#else
+ if (setjmp(png_ptr->jmpbuf)) {
++#endif
+ /* Free all of the memory associated with the png_ptr and info_ptr */
+ delete [] row_pointers;
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+@@ -70,16 +78,35 @@
+ /* read the file information */
+ png_read_info(png_ptr, info_ptr);
+
++ png_uint_32 _width,_height;
++ int _bit_depth,_color_type,_interlace_type,_compression_type,_filter_type;
++#if PNG_LIBPNG_VER > 10399
++ png_get_IHDR(png_ptr,info_ptr,&_width,&_height,&_bit_depth,&_color_type,
++ &_interlace_type,&_compression_type,&_filter_type);
++#else
++ _width=info_ptr->width;
++ _height=info_ptr->height;
++ _bit_depth=info_ptr->bit_depth;
++ _color_type=info_ptr->color_type;
++ _interlace_type=info_ptr->interlace_type;
++ _compression_type=info_ptr->compression_type;
++ _filter_type=info_ptr->filter_type;
++#endif
++
+ if (info.nEscape == -1){
+- head.biWidth = info_ptr->width;
+- head.biHeight= info_ptr->height;
++ head.biWidth = _width;
++ head.biHeight= _height;
+ info.dwType = CXIMAGE_FORMAT_PNG;
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ /* calculate new number of channels */
+ int channels=0;
+- switch(info_ptr->color_type){
++ switch(_color_type){
+ case PNG_COLOR_TYPE_GRAY:
+ case PNG_COLOR_TYPE_PALETTE:
+ channels = 1;
+@@ -101,71 +128,108 @@
+ break;
+ default:
+ strcpy(info.szLastError,"unknown PNG color type");
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ //find the right pixel depth used for cximage
++#if PNG_LIBPNG_VER > 10399
++ int pixel_depth = _bit_depth * png_get_channels(png_ptr,info_ptr);
++#else
+ int pixel_depth = info_ptr->pixel_depth;
++#endif
+ if (channels == 1 && pixel_depth>8) pixel_depth=8;
+ if (channels == 2) pixel_depth=8;
+ if (channels >= 3) pixel_depth=24;
+
+- if (!Create(info_ptr->width, info_ptr->height, pixel_depth, CXIMAGE_FORMAT_PNG)){
++ if (!Create(_width, _height, pixel_depth, CXIMAGE_FORMAT_PNG)){
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ /* get metrics */
+- switch (info_ptr->phys_unit_type)
++ png_uint_32 _x_pixels_per_unit,_y_pixels_per_unit;
++ int _phys_unit_type;
++#if PNG_LIBPNG_VER > 10399
++ png_get_pHYs(png_ptr,info_ptr,&_x_pixels_per_unit,&_y_pixels_per_unit,&_phys_unit_type);
++#else
++ _x_pixels_per_unit=info_ptr->x_pixels_per_unit;
++ _y_pixels_per_unit=info_ptr->y_pixels_per_unit;
++ _phys_unit_type=info_ptr->phys_unit_type;
++#endif
++ switch (_phys_unit_type)
+ {
+ case PNG_RESOLUTION_UNKNOWN:
+- SetXDPI(info_ptr->x_pixels_per_unit);
+- SetYDPI(info_ptr->y_pixels_per_unit);
++ SetXDPI(_x_pixels_per_unit);
++ SetYDPI(_y_pixels_per_unit);
+ break;
+ case PNG_RESOLUTION_METER:
+- SetXDPI((long)floor(info_ptr->x_pixels_per_unit * 254.0 / 10000.0 + 0.5));
+- SetYDPI((long)floor(info_ptr->y_pixels_per_unit * 254.0 / 10000.0 + 0.5));
++ SetXDPI((long)floor(_x_pixels_per_unit * 254.0 / 10000.0 + 0.5));
++ SetYDPI((long)floor(_y_pixels_per_unit * 254.0 / 10000.0 + 0.5));
+ break;
+ }
+
+- if (info_ptr->num_palette>0){
+- SetPalette((rgb_color*)info_ptr->palette,info_ptr->num_palette);
+- SetClrImportant(info_ptr->num_palette);
+- } else if (info_ptr->bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
++ int _num_palette;
++ png_colorp _palette;
++#if PNG_LIBPNG_VER > 10399
++ png_get_PLTE(png_ptr,info_ptr,&_palette,&_num_palette);
++#else
++ _num_palette=info_ptr->num_palette;
++ _palette=info_ptr->palette;
++#endif
++ if (_num_palette>0){
++ SetPalette((rgb_color*)_palette,_num_palette);
++ SetClrImportant(_num_palette);
++ } else if (_bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
+ SetPaletteColor(0,0,0,0);
+ SetPaletteColor(1,85,85,85);
+ SetPaletteColor(2,170,170,170);
+ SetPaletteColor(3,255,255,255);
+ } else SetGrayPalette(); //<DP> needed for grayscale PNGs
+
+- int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3;
++ int nshift = max(0,(_bit_depth>>3)-1)<<3;
+
+- if (info_ptr->num_trans!=0){ //palette transparency
+- if (info_ptr->num_trans==1){
+- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE){
++ png_bytep _trans_alpha;
++ int _num_trans;
++ png_color_16p _trans_color;
++#if PNG_LIBPNG_VER > 10399
++ png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color);
++#else
++ _num_trans=info_ptr->num_trans;
++#endif
++ if (_num_trans!=0){ //palette transparency
++ if (_num_trans==1){
++ if (_color_type == PNG_COLOR_TYPE_PALETTE){
+ #if PNG_LIBPNG_VER > 10399
+- info.nBkgndIndex = info_ptr->trans_color.index;
++ info.nBkgndIndex = _trans_color->index;
+ #else
+ info.nBkgndIndex = info_ptr->trans_values.index;
+ #endif
+ } else{
+ #if PNG_LIBPNG_VER > 10399
+- info.nBkgndIndex = info_ptr->trans_color.gray>>nshift;
++ info.nBkgndIndex = _trans_color->gray>>nshift;
+ #else
+ info.nBkgndIndex = info_ptr->trans_values.gray>>nshift;
+ #endif
+ }
+ }
+- if (info_ptr->num_trans>1){
++ if (_num_trans>1){
+ RGBQUAD* pal=GetPalette();
+ if (pal){
+ DWORD ip;
+- for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
++ for (ip=0;ip<min(head.biClrUsed,(unsigned long)_num_trans);ip++)
+ #if PNG_LIBPNG_VER > 10399
+- pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
++ pal[ip].rgbReserved=_trans_alpha[ip];
+ #else
+ pal[ip].rgbReserved=info_ptr->trans[ip];
+ #endif
+- for (ip=info_ptr->num_trans;ip<head.biClrUsed;ip++){
++ for (ip=_num_trans;ip<head.biClrUsed;ip++){
+ pal[ip].rgbReserved=255;
+ }
+ info.bAlphaPaletteEnabled=true;
+@@ -174,14 +238,12 @@
+ }
+
+ if (channels == 3){ //check RGB binary transparency
+- png_bytep trans;
+- int num_trans;
+- png_color_16 *image_background;
+- if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &image_background)){
+-#if PNG_LIBPNG_VER > 10399
+- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_color.red>>nshift);
+- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_color.green>>nshift);
+- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_color.blue>>nshift);
++ /* seems unnecessary to call again, but the conditional must be important so... */
++ if (png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color)){
++#if PNG_LIBPNG_VER > 10399
++ info.nBkgndColor.rgbRed = (BYTE)(_trans_color->red>>nshift);
++ info.nBkgndColor.rgbGreen = (BYTE)(_trans_color->green>>nshift);
++ info.nBkgndColor.rgbBlue = (BYTE)(_trans_color->blue>>nshift);
+ #else
+ info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_values.red>>nshift);
+ info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_values.green>>nshift);
+@@ -202,15 +264,24 @@
+ }
+
+ // <vho> - flip the RGB pixels to BGR (or RGBA to BGRA)
+- if (info_ptr->color_type & PNG_COLOR_MASK_COLOR){
++ if (_color_type & PNG_COLOR_MASK_COLOR){
+ png_set_bgr(png_ptr);
+ }
+
+ // <vho> - handle cancel
+- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
++ if (info.nEscape)
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
++ longjmp(png_ptr->jmpbuf, 1);
++#endif
+
+ // row_bytes is the width x number of channels x (bit-depth / 8)
++#if PNG_LIBPNG_VER > 10399
++ row_pointers = new BYTE[png_get_rowbytes(png_ptr,info_ptr) + 8];
++#else
+ row_pointers = new BYTE[info_ptr->rowbytes + 8];
++#endif
+
+ // turn on interlace handling
+ int number_passes = png_set_interlace_handling(png_ptr);
+@@ -221,8 +292,12 @@
+ SetCodecOption(0);
+ }
+
+- int chan_offset = info_ptr->bit_depth >> 3;
++ int chan_offset = _bit_depth >> 3;
++#if PNG_LIBPNG_VER > 10399
++ int pixel_offset = (_bit_depth * png_get_channels(png_ptr,info_ptr)) >> 3;
++#else
+ int pixel_offset = info_ptr->pixel_depth >> 3;
++#endif
+
+ for (int pass=0; pass < number_passes; pass++) {
+ iter.Upset();
+@@ -230,7 +305,12 @@
+ do {
+
+ // <vho> - handle cancel
+- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
++ if (info.nEscape)
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
++ longjmp(png_ptr->jmpbuf, 1);
++#endif
+
+ #if CXIMAGE_SUPPORT_ALPHA // <vho>
+ if (AlphaIsValid()) {
+@@ -241,7 +321,7 @@
+ BYTE* prow= iter.GetRow(ay);
+
+ //recover data from previous scan
+- if (info_ptr->interlace_type && pass>0 && pass!=7){
++ if (_interlace_type && pass>0 && pass!=7){
+ for(ax=0;ax<head.biWidth;ax++){
+ long px = ax * pixel_offset;
+ if (channels == 2){
+@@ -278,10 +358,14 @@
+ #endif // CXIMAGE_SUPPORT_ALPHA // vho
+ {
+ //recover data from previous scan
+- if (info_ptr->interlace_type && pass>0){
++ if (_interlace_type && pass>0){
++#if PNG_LIBPNG_VER > 10399
++ iter.GetRow(row_pointers, png_get_rowbytes(png_ptr,info_ptr));
++#else
+ iter.GetRow(row_pointers, info_ptr->rowbytes);
++#endif
+ //re-expand buffer for images with bit depth > 8
+- if (info_ptr->bit_depth > 8){
++ if (_bit_depth > 8){
+ for(long ax=(head.biWidth*channels-1);ax>=0;ax--)
+ row_pointers[ax*chan_offset] = row_pointers[ax];
+ }
+@@ -291,15 +375,19 @@
+ png_read_row(png_ptr, row_pointers, NULL);
+
+ //shrink 16 bit depth images down to 8 bits
+- if (info_ptr->bit_depth > 8){
++ if (_bit_depth > 8){
+ for(long ax=0;ax<(head.biWidth*channels);ax++)
+ row_pointers[ax] = row_pointers[ax*chan_offset];
+ }
+
+ //copy the pixels
++#if PNG_LIBPNG_VER > 10399
++ iter.SetRow(row_pointers, png_get_rowbytes(png_ptr,info_ptr));
++#else
+ iter.SetRow(row_pointers, info_ptr->rowbytes);
++#endif
+ //<DP> expand 2 bpp images only in the last pass
+- if (info_ptr->bit_depth==2 && pass==(number_passes-1))
++ if (_bit_depth==2 && pass==(number_passes-1))
+ expand2to4bpp(iter.GetRow());
+
+ //go on
+@@ -361,9 +449,13 @@
+ /* Set error handling. REQUIRED if you aren't supplying your own
+ * error hadnling functions in the png_create_write_struct() call.
+ */
++#if PNG_LIBPNG_VER > 10399
++ if (setjmp(png_jmpbuf(png_ptr))){
++#else
+ if (setjmp(png_ptr->jmpbuf)){
+ /* If we get here, we had a problem reading the file */
+ if (info_ptr->palette) free(info_ptr->palette);
++#endif
+ png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr);
+ cx_throw("Error saving PNG file");
+ }
+@@ -372,9 +464,23 @@
+ //png_init_io(png_ptr, hFile);
+
+ // use custom I/O functions
+- png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data);
++ png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data);
+
+ /* set the file information here */
++#if PNG_LIBPNG_VER > 10399
++ /* use variables to hold the values so it isnt necessary to png_get them later */
++ png_uint_32 _width,_height;
++ int _bit_depth,_color_type,_interlace_type,_compression_type,_filter_type;
++ png_byte _channels,_pixel_depth;
++
++ _width = GetWidth();
++ _height = GetHeight();
++ _pixel_depth = (BYTE)GetBpp();
++ _channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1;
++ _bit_depth = (BYTE)(GetBpp()/_channels);
++ _compression_type = PNG_COMPRESSION_TYPE_DEFAULT;
++ _filter_type = PNG_FILTER_TYPE_DEFAULT;
++#else
+ info_ptr->width = GetWidth();
+ info_ptr->height = GetHeight();
+ info_ptr->pixel_depth = (BYTE)GetBpp();
+@@ -382,13 +488,22 @@
+ info_ptr->bit_depth = (BYTE)(GetBpp()/info_ptr->channels);
+ info_ptr->compression_type = info_ptr->filter_type = 0;
+ info_ptr->valid = 0;
++#endif
+
+ switch(GetCodecOption(CXIMAGE_FORMAT_PNG)){
+ case 1:
++#if PNG_LIBPNG_VER > 10399
++ _interlace_type = PNG_INTERLACE_ADAM7;
++#else
+ info_ptr->interlace_type = PNG_INTERLACE_ADAM7;
++#endif
+ break;
+ default:
++#if PNG_LIBPNG_VER > 10399
++ _interlace_type = PNG_INTERLACE_NONE;
++#else
+ info_ptr->interlace_type = PNG_INTERLACE_NONE;
++#endif
+ }
+
+ /* set compression level */
+@@ -398,22 +513,47 @@
+
+ if (GetNumColors()){
+ if (bGrayScale){
++#if PNG_LIBPNG_VER > 10399
++ _color_type = PNG_COLOR_TYPE_GRAY;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
++#endif
+ } else {
++#if PNG_LIBPNG_VER > 10399
++ _color_type = PNG_COLOR_TYPE_PALETTE;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
++#endif
+ }
+ } else {
++#if PNG_LIBPNG_VER > 10399
++ _color_type = PNG_COLOR_TYPE_RGB;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_RGB;
++#endif
+ }
+ #if CXIMAGE_SUPPORT_ALPHA
+ if (AlphaIsValid()){
++#if PNG_LIBPNG_VER > 10399
++ _color_type |= PNG_COLOR_MASK_ALPHA;
++ _channels++;
++ _bit_depth = 8;
++ _pixel_depth += 8;
++#else
+ info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
+ info_ptr->channels++;
+ info_ptr->bit_depth = 8;
+ info_ptr->pixel_depth += 8;
++#endif
+ }
+ #endif
+
++#if PNG_LIBPNG_VER > 10399
++ /* set the header here, since we're done modifying these values */
++ png_set_IHDR(png_ptr,info_ptr,_width,_height,_bit_depth,_color_type,_interlace_type,
++ _compression_type,_filter_type);
++#endif
++
+ /* set background */
+ png_color_16 image_background={ 0, 255, 255, 255, 0 };
+ RGBQUAD tc = GetTransColor();
+@@ -427,22 +567,24 @@
+ /* set metrics */
+ png_set_pHYs(png_ptr, info_ptr, head.biXPelsPerMeter, head.biYPelsPerMeter, PNG_RESOLUTION_METER);
+
++#if PNG_LIBPNG_VER <= 10399
+ png_set_IHDR(png_ptr, info_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth,
+ info_ptr->color_type, info_ptr->interlace_type,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
++#endif
+
+ //<DP> simple transparency
+ if (info.nBkgndIndex >= 0){
+- info_ptr->num_trans = 1;
+- info_ptr->valid |= PNG_INFO_tRNS;
+ #if PNG_LIBPNG_VER > 10399
+- info_ptr->trans_alpha = trans;
+- info_ptr->trans_color.index = (BYTE)info.nBkgndIndex;
+- info_ptr->trans_color.red = tc.rgbRed;
+- info_ptr->trans_color.green = tc.rgbGreen;
+- info_ptr->trans_color.blue = tc.rgbBlue;
+- info_ptr->trans_color.gray = info_ptr->trans_color.index;
++ png_color_16 _trans_color;
++ _trans_color.index = (BYTE)info.nBkgndIndex;
++ _trans_color.red = tc.rgbRed;
++ _trans_color.green = tc.rgbGreen;
++ _trans_color.blue = tc.rgbBlue;
++ _trans_color.gray = _trans_color.index;
+ #else
++ info_ptr->num_trans = 1;
++ info_ptr->valid |= PNG_INFO_tRNS;
+ info_ptr->trans = trans;
+ info_ptr->trans_values.index = (BYTE)info.nBkgndIndex;
+ info_ptr->trans_values.red = tc.rgbRed;
+@@ -454,34 +596,53 @@
+ // the transparency indexes start from 0 for non grayscale palette
+ if (!bGrayScale && head.biClrUsed && info.nBkgndIndex)
+ SwapIndex(0,(BYTE)info.nBkgndIndex);
++
++#if PNG_LIBPNG_VER > 10399
++ png_set_tRNS(png_ptr,info_ptr,(png_bytep)trans,1,&_trans_color);
++#endif
+ }
+
+ /* set the palette if there is one */
++#if PNG_LIBPNG_VER > 10399
++ png_colorp _palette;
++#endif
+ if (GetPalette()){
++#if PNG_LIBPNG_VER <= 10399
+ if (!bGrayScale){
+ info_ptr->valid |= PNG_INFO_PLTE;
+ }
++#endif
+
+ int nc = GetClrImportant();
+ if (nc==0) nc = GetNumColors();
+
++ // copy the palette colors
++#if PNG_LIBPNG_VER > 10399
++ _palette = new png_color[nc];
++#else
++ info_ptr->palette = new png_color[nc];
++ info_ptr->num_palette = (png_uint_16) nc;
++#endif
++ for (int i=0; i<nc; i++)
++#if PNG_LIBPNG_VER > 10399
++ GetPaletteColor(i, &_palette[i].red, &_palette[i].green, &_palette[i].blue);
++
++ png_set_PLTE(png_ptr,info_ptr,_palette,nc);
++#else
++ GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
++#endif
++
+ if (info.bAlphaPaletteEnabled){
+ for(WORD ip=0; ip<nc;ip++)
+ trans[ip]=GetPaletteColor((BYTE)ip).rgbReserved;
+- info_ptr->num_trans = (WORD)nc;
+- info_ptr->valid |= PNG_INFO_tRNS;
+ #if PNG_LIBPNG_VER > 10399
+- info_ptr->trans_alpha = trans;
++ png_set_tRNS(png_ptr,info_ptr,(png_bytep)trans,nc,NULL);
+ #else
++ info_ptr->num_trans = (WORD)nc;
++ info_ptr->valid |= PNG_INFO_tRNS;
+ info_ptr->trans = trans;
+ #endif
+ }
+-
+- // copy the palette colors
+- info_ptr->palette = new png_color[nc];
+- info_ptr->num_palette = (png_uint_16) nc;
+- for (int i=0; i<nc; i++)
+- GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
+ }
+
+ #if CXIMAGE_SUPPORT_ALPHA // <vho>
+@@ -495,8 +656,12 @@
+ } } }
+ #endif // CXIMAGE_SUPPORT_ALPHA // <vho>
+
++#if PNG_LIBPNG_VER > 10399
++ int row_size = max(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
++#else
+ int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
+ info_ptr->rowbytes = row_size;
++#endif
+ BYTE *row_pointers = new BYTE[row_size];
+
+ /* write the file information */
+@@ -514,7 +679,11 @@
+ if (AlphaIsValid()){
+ for (long ax=head.biWidth-1; ax>=0;ax--){
+ c = BlindGetPixelColor(ax,ay);
++#if PNG_LIBPNG_VER > 10399
++ int px = ax * _channels;
++#else
+ int px = ax * info_ptr->channels;
++#endif
+ if (!bGrayScale){
+ row_pointers[px++]=c.rgbRed;
+ row_pointers[px++]=c.rgbGreen;
+@@ -529,7 +698,11 @@
+ #endif //CXIMAGE_SUPPORT_ALPHA // <vho>
+ {
+ iter.GetRow(row_pointers, row_size);
++#if PNG_LIBPNG_VER > 10399
++ if (_color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP
++#else
+ if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP
++#endif
+ RGBtoBGR(row_pointers, row_size);
+ png_write_row(png_ptr, row_pointers);
+ }
+@@ -546,9 +719,14 @@
+ png_write_end(png_ptr, info_ptr);
+
+ /* if you malloced the palette, free it here */
++#if PNG_LIBPNG_VER > 10399
++ if (_palette){
++ delete [] (_palette);
++#else
+ if (info_ptr->palette){
+ delete [] (info_ptr->palette);
+ info_ptr->palette = NULL;
++#endif
+ }
+
+ /* clean up after the write, and free any memory allocated */
diff --git a/media-tv/xbmc/files/xbmc-11.0-libpng-1.5.patch b/media-tv/xbmc/files/xbmc-11.0-libpng-1.5.patch
new file mode 100644
index 00000000..18c589a1
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-11.0-libpng-1.5.patch
@@ -0,0 +1,605 @@
+fix building with newer libpng. patch by Ian Stakenvicius.
+
+https://bugs.gentoo.org/380127
+
+--- a/lib/cximage-6.0/CxImage/ximapng.cpp
++++ b/lib/cximage-6.0/CxImage/ximapng.cpp
+@@ -15,7 +15,11 @@
+ void CxImagePNG::ima_png_error(png_struct *png_ptr, char *message)
+ {
+ strcpy(info.szLastError,message);
++#if PNG_LIBPNG_VER > 10499
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+ ////////////////////////////////////////////////////////////////////////////////
+ #if CXIMAGE_SUPPORT_DECODE
+@@ -62,7 +66,11 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ /* Set error handling if you are using the setjmp/longjmp method (this is
+ * the normal method of doing things with libpng). REQUIRED unless you
+ * set up your own error handlers in the png_create_read_struct() earlier. */
++#if PNG_LIBPNG_VER > 10499
++ if (setjmp(png_jmpbuf(png_ptr))) {
++#else
+ if (setjmp(png_ptr->jmpbuf)) {
++#endif
+ /* Free all of the memory associated with the png_ptr and info_ptr */
+ delete [] row_pointers;
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+@@ -76,16 +84,34 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ /* read the file information */
+ png_read_info(png_ptr, info_ptr);
+
++#if PNG_LIBPNG_VER > 10499
++ png_uint_32 _width,_height;
++ int _bit_depth,_color_type,_interlace_type,_compression_type,_filter_type;
++ png_get_IHDR(png_ptr,info_ptr,&_width,&_height,&_bit_depth,&_color_type,
++ &_interlace_type,&_compression_type,&_filter_type);
++
++ if (info.nEscape == -1){
++ head.biWidth = _width;
++ head.biHeight= _height;
++ info.dwType = CXIMAGE_FORMAT_PNG;
++ longjmp(png_jmpbuf(png_ptr), 1);
++ }
++#else
+ if (info.nEscape == -1){
+ head.biWidth = info_ptr->width;
+ head.biHeight= info_ptr->height;
+ info.dwType = CXIMAGE_FORMAT_PNG;
+ longjmp(png_ptr->jmpbuf, 1);
+ }
++#endif
+
+ /* calculate new number of channels */
+ int channels=0;
++#if PNG_LIBPNG_VER > 10499
++ switch(_color_type){
++#else
+ switch(info_ptr->color_type){
++#endif
+ case PNG_COLOR_TYPE_GRAY:
+ case PNG_COLOR_TYPE_PALETTE:
+ channels = 1;
+@@ -101,20 +127,49 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ break;
+ default:
+ strcpy(info.szLastError,"unknown PNG color type");
++#if PNG_LIBPNG_VER > 10499
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ //find the right pixel depth used for cximage
++#if PNG_LIBPNG_VER > 10499
++ int pixel_depth = _bit_depth * png_get_channels(png_ptr,info_ptr);
++#else
+ int pixel_depth = info_ptr->pixel_depth;
++#endif
+ if (channels == 1 && pixel_depth>8) pixel_depth=8;
+ if (channels == 2) pixel_depth=8;
+ if (channels >= 3) pixel_depth=24;
+
++#if PNG_LIBPNG_VER > 10499
++ if (!Create(_width, _height, pixel_depth, CXIMAGE_FORMAT_PNG)){
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ if (!Create(info_ptr->width, info_ptr->height, pixel_depth, CXIMAGE_FORMAT_PNG)){
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ /* get metrics */
++#if PNG_LIBPNG_VER > 10499
++ png_uint_32 _x_pixels_per_unit,_y_pixels_per_unit;
++ int _phys_unit_type;
++ png_get_pHYs(png_ptr,info_ptr,&_x_pixels_per_unit,&_y_pixels_per_unit,&_phys_unit_type);
++ switch (_phys_unit_type)
++ {
++ case PNG_RESOLUTION_UNKNOWN:
++ SetXDPI(_x_pixels_per_unit);
++ SetYDPI(_y_pixels_per_unit);
++ break;
++ case PNG_RESOLUTION_METER:
++ SetXDPI((long)floor(_x_pixels_per_unit * 254.0 / 10000.0 + 0.5));
++ SetYDPI((long)floor(_y_pixels_per_unit * 254.0 / 10000.0 + 0.5));
++ break;
++ }
++#else
+ switch (info_ptr->phys_unit_type)
+ {
+ case PNG_RESOLUTION_UNKNOWN:
+@@ -126,46 +181,94 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ SetYDPI((long)floor(info_ptr->y_pixels_per_unit * 254.0 / 10000.0 + 0.5));
+ break;
+ }
++#endif
+
++#if PNG_LIBPNG_VER > 10499
++ int _num_palette;
++ png_colorp _palette;
++ png_uint_32 _palette_ret;
++ _palette_ret = png_get_PLTE(png_ptr,info_ptr,&_palette,&_num_palette);
++ if (_palette_ret && _num_palette>0){
++ SetPalette((rgb_color*)_palette,_num_palette);
++ SetClrImportant(_num_palette);
++ } else if (_bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
++#else
+ if (info_ptr->num_palette>0){
+ SetPalette((rgb_color*)info_ptr->palette,info_ptr->num_palette);
+ SetClrImportant(info_ptr->num_palette);
+ } else if (info_ptr->bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
++#endif
+ SetPaletteColor(0,0,0,0);
+ SetPaletteColor(1,85,85,85);
+ SetPaletteColor(2,170,170,170);
+ SetPaletteColor(3,255,255,255);
+ } else SetGrayPalette(); //<DP> needed for grayscale PNGs
+
++#if PNG_LIBPNG_VER > 10499
++ int nshift = max(0,(_bit_depth>>3)-1)<<3;
++#else
+ int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3;
++#endif
+
++#if PNG_LIBPNG_VER > 10499
++ png_bytep _trans_alpha;
++ int _num_trans;
++ png_color_16p _trans_color;
++ png_uint_32 _trans_ret;
++ _trans_ret = png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color);
++ if (_trans_ret && _num_trans!=0){ //palette transparency
++ if (_num_trans==1){
++ if (_color_type == PNG_COLOR_TYPE_PALETTE){
++#else
+ if (info_ptr->num_trans!=0){ //palette transparency
+ if (info_ptr->num_trans==1){
+ if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE){
++#endif
++#if PNG_LIBPNG_VER > 10499
++ info.nBkgndIndex = _trans_color->index;
++#else
+ #if PNG_LIBPNG_VER > 10399
+ info.nBkgndIndex = info_ptr->trans_color.index;
+ #else
+ info.nBkgndIndex = info_ptr->trans_values.index;
+ #endif
++#endif
+ } else{
++#if PNG_LIBPNG_VER > 10499
++ info.nBkgndIndex = _trans_color->gray>>nshift;
++#else
+ #if PNG_LIBPNG_VER > 10399
+ info.nBkgndIndex = info_ptr->trans_color.gray>>nshift;
+ #else
+ info.nBkgndIndex = info_ptr->trans_values.gray>>nshift;
+ #endif
++#endif
+ }
+ }
++#if PNG_LIBPNG_VER > 10499
++ if (_num_trans>1 && _trans_alpha!=NULL){
++#else
+ if (info_ptr->num_trans>1){
++#endif
+ RGBQUAD* pal=GetPalette();
+ if (pal){
+ DWORD ip;
++#if PNG_LIBPNG_VER > 10499
++ for (ip=0;ip<min(head.biClrUsed,(unsigned long)_num_trans);ip++)
++ pal[ip].rgbReserved=_trans_alpha[ip];
++#else
+ for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
+ #if PNG_LIBPNG_VER > 10399
+ pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
+ #else
+ pal[ip].rgbReserved=info_ptr->trans[ip];
+ #endif
++#endif
++#if PNG_LIBPNG_VER > 10499
++ for (ip=_num_trans;ip<head.biClrUsed;ip++){
++#else
+ for (ip=info_ptr->num_trans;ip<head.biClrUsed;ip++){
++#endif
+ pal[ip].rgbReserved=255;
+ }
+ info.bAlphaPaletteEnabled=true;
+@@ -178,6 +281,11 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ int num_trans;
+ png_color_16 *image_background;
+ if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &image_background)){
++#if PNG_LIBPNG_VER > 10499
++ info.nBkgndColor.rgbRed = (BYTE)(_trans_color->red>>nshift);
++ info.nBkgndColor.rgbGreen = (BYTE)(_trans_color->green>>nshift);
++ info.nBkgndColor.rgbBlue = (BYTE)(_trans_color->blue>>nshift);
++#else
+ #if PNG_LIBPNG_VER > 10399
+ info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_color.red>>nshift);
+ info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_color.green>>nshift);
+@@ -187,6 +295,7 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_values.green>>nshift);
+ info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_values.blue>>nshift);
+ #endif
++#endif
+ info.nBkgndColor.rgbReserved = 0;
+ info.nBkgndIndex = 0;
+ }
+@@ -202,15 +311,27 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ }
+
+ // <vho> - flip the RGB pixels to BGR (or RGBA to BGRA)
++#if PNG_LIBPNG_VER > 10499
++ if (_color_type & PNG_COLOR_MASK_COLOR){
++#else
+ if (info_ptr->color_type & PNG_COLOR_MASK_COLOR){
++#endif
+ png_set_bgr(png_ptr);
+ }
+
+ // <vho> - handle cancel
++#if PNG_LIBPNG_VER > 10499
++ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
++#endif
+
+ // row_bytes is the width x number of channels x (bit-depth / 8)
++#if PNG_LIBPNG_VER > 10499
++ row_pointers = new BYTE[png_get_rowbytes(png_ptr,info_ptr) + 8];
++#else
+ row_pointers = new BYTE[info_ptr->rowbytes + 8];
++#endif
+
+ // turn on interlace handling
+ int number_passes = png_set_interlace_handling(png_ptr);
+@@ -221,8 +342,16 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ SetCodecOption(0);
+ }
+
++#if PNG_LIBPNG_VER > 10499
++ int chan_offset = _bit_depth >> 3;
++#else
+ int chan_offset = info_ptr->bit_depth >> 3;
++#endif
++#if PNG_LIBPNG_VER > 10499
++ int pixel_offset = (_bit_depth * png_get_channels(png_ptr,info_ptr)) >> 3;
++#else
+ int pixel_offset = info_ptr->pixel_depth >> 3;
++#endif
+
+ for (int pass=0; pass < number_passes; pass++) {
+ iter.Upset();
+@@ -230,7 +359,11 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ do {
+
+ // <vho> - handle cancel
++#if PNG_LIBPNG_VER > 10499
++ if (info.nEscape) longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
++#endif
+
+ #if CXIMAGE_SUPPORT_ALPHA // <vho>
+ if (AlphaIsValid()) {
+@@ -241,7 +374,11 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ BYTE* prow= iter.GetRow(ay);
+
+ //recover data from previous scan
++#if PNG_LIBPNG_VER > 10499
++ if (_interlace_type && pass>0 && pass!=7){
++#else
+ if (info_ptr->interlace_type && pass>0 && pass!=7){
++#endif
+ for(ax=0;ax<head.biWidth;ax++){
+ long px = ax * pixel_offset;
+ if (channels == 2){
+@@ -278,10 +415,17 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ #endif // CXIMAGE_SUPPORT_ALPHA // vho
+ {
+ //recover data from previous scan
++#if PNG_LIBPNG_VER > 10499
++ if (_interlace_type && pass>0){
++ iter.GetRow(row_pointers, png_get_rowbytes(png_ptr,info_ptr));
++ //re-expand buffer for images with bit depth > 8
++ if (_bit_depth > 8){
++#else
+ if (info_ptr->interlace_type && pass>0){
+ iter.GetRow(row_pointers, info_ptr->rowbytes);
+ //re-expand buffer for images with bit depth > 8
+ if (info_ptr->bit_depth > 8){
++#endif
+ for(long ax=(head.biWidth*channels-1);ax>=0;ax--)
+ row_pointers[ax*chan_offset] = row_pointers[ax];
+ }
+@@ -291,15 +435,27 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ png_read_row(png_ptr, row_pointers, NULL);
+
+ //shrink 16 bit depth images down to 8 bits
++#if PNG_LIBPNG_VER > 10499
++ if (_bit_depth > 8){
++#else
+ if (info_ptr->bit_depth > 8){
++#endif
+ for(long ax=0;ax<(head.biWidth*channels);ax++)
+ row_pointers[ax] = row_pointers[ax*chan_offset];
+ }
+
+ //copy the pixels
++#if PNG_LIBPNG_VER > 10499
++ iter.SetRow(row_pointers, png_get_rowbytes(png_ptr,info_ptr));
++#else
+ iter.SetRow(row_pointers, info_ptr->rowbytes);
++#endif
+ //<DP> expand 2 bpp images only in the last pass
++#if PNG_LIBPNG_VER > 10499
++ if (_bit_depth==2 && pass==(number_passes-1))
++#else
+ if (info_ptr->bit_depth==2 && pass==(number_passes-1))
++#endif
+ expand2to4bpp(iter.GetRow());
+
+ //go on
+@@ -361,9 +517,13 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ /* Set error handling. REQUIRED if you aren't supplying your own
+ * error hadnling functions in the png_create_write_struct() call.
+ */
++#if PNG_LIBPNG_VER > 10499
++ if (setjmp(png_jmpbuf(png_ptr))){
++#else
+ if (setjmp(png_ptr->jmpbuf)){
+ /* If we get here, we had a problem reading the file */
+ if (info_ptr->palette) free(info_ptr->palette);
++#endif
+ png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr);
+ cx_throw("Error saving PNG file");
+ }
+@@ -372,9 +532,23 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ //png_init_io(png_ptr, hFile);
+
+ // use custom I/O functions
+- png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data);
++ png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data);
+
+ /* set the file information here */
++#if PNG_LIBPNG_VER > 10499
++ /* use variables to hold the values so it isnt necessary to png_get them later */
++ png_uint_32 _width,_height;
++ int _bit_depth,_color_type,_interlace_type,_compression_type,_filter_type;
++ png_byte _channels,_pixel_depth;
++
++ _width = GetWidth();
++ _height = GetHeight();
++ _pixel_depth = (BYTE)GetBpp();
++ _channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1;
++ _bit_depth = (BYTE)(GetBpp()/_channels);
++ _compression_type = PNG_COMPRESSION_TYPE_DEFAULT;
++ _filter_type = PNG_FILTER_TYPE_DEFAULT;
++#else
+ info_ptr->width = GetWidth();
+ info_ptr->height = GetHeight();
+ info_ptr->pixel_depth = (BYTE)GetBpp();
+@@ -382,13 +556,22 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ info_ptr->bit_depth = (BYTE)(GetBpp()/info_ptr->channels);
+ info_ptr->compression_type = info_ptr->filter_type = 0;
+ info_ptr->valid = 0;
++#endif
+
+ switch(GetCodecOption(CXIMAGE_FORMAT_PNG)){
+ case 1:
++#if PNG_LIBPNG_VER > 10499
++ _interlace_type = PNG_INTERLACE_ADAM7;
++#else
+ info_ptr->interlace_type = PNG_INTERLACE_ADAM7;
++#endif
+ break;
+ default:
++#if PNG_LIBPNG_VER > 10499
++ _interlace_type = PNG_INTERLACE_NONE;
++#else
+ info_ptr->interlace_type = PNG_INTERLACE_NONE;
++#endif
+ }
+
+ /* set compression level */
+@@ -398,19 +581,38 @@ bool CxImagePNG::Encode(CxFile *hFile)
+
+ if (GetNumColors()){
+ if (bGrayScale){
++#if PNG_LIBPNG_VER > 10499
++ _color_type = PNG_COLOR_TYPE_GRAY;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
++#endif
+ } else {
++#if PNG_LIBPNG_VER > 10499
++ _color_type = PNG_COLOR_TYPE_PALETTE;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
++#endif
+ }
+ } else {
++#if PNG_LIBPNG_VER > 10499
++ _color_type = PNG_COLOR_TYPE_RGB;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_RGB;
++#endif
+ }
+ #if CXIMAGE_SUPPORT_ALPHA
+ if (AlphaIsValid()){
++#if PNG_LIBPNG_VER > 10499
++ _color_type |= PNG_COLOR_MASK_ALPHA;
++ _channels++;
++ _bit_depth = 8;
++ _pixel_depth += 8;
++#else
+ info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
+ info_ptr->channels++;
+ info_ptr->bit_depth = 8;
+ info_ptr->pixel_depth += 8;
++#endif
+ }
+ #endif
+
+@@ -427,14 +629,30 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ /* set metrics */
+ png_set_pHYs(png_ptr, info_ptr, head.biXPelsPerMeter, head.biYPelsPerMeter, PNG_RESOLUTION_METER);
+
++#if PNG_LIBPNG_VER > 10499
++ png_set_IHDR(png_ptr,info_ptr,_width,_height,_bit_depth,_color_type,_interlace_type,
++ _compression_type,_filter_type);
++#else
+ png_set_IHDR(png_ptr, info_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth,
+ info_ptr->color_type, info_ptr->interlace_type,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
++#endif
+
+ //<DP> simple transparency
+ if (info.nBkgndIndex >= 0){
++#if PNG_LIBPNG_VER <= 10499
+ info_ptr->num_trans = 1;
+ info_ptr->valid |= PNG_INFO_tRNS;
++#endif
++#if PNG_LIBPNG_VER > 10499
++ png_color_16 _trans_color;
++ _trans_color.index = (BYTE)info.nBkgndIndex;
++ _trans_color.red = tc.rgbRed;
++ _trans_color.green = tc.rgbGreen;
++ _trans_color.blue = tc.rgbBlue;
++ _trans_color.gray = _trans_color.index;
++ png_set_tRNS(png_ptr,info_ptr,(png_bytep)trans,1,&_trans_color);
++#else
+ #if PNG_LIBPNG_VER > 10399
+ info_ptr->trans_alpha = trans;
+ info_ptr->trans_color.index = (BYTE)info.nBkgndIndex;
+@@ -450,6 +668,7 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ info_ptr->trans_values.blue = tc.rgbBlue;
+ info_ptr->trans_values.gray = info_ptr->trans_values.index;
+ #endif
++#endif
+
+ // the transparency indexes start from 0 for non grayscale palette
+ if (!bGrayScale && head.biClrUsed && info.nBkgndIndex)
+@@ -457,10 +676,16 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ }
+
+ /* set the palette if there is one */
++#if PNG_LIBPNG_VER > 10499
++ png_colorp _palette = NULL;
++ if (GetPalette()){
++ /* png_set_PLTE() will be called once the palette is ready */
++#else
+ if (GetPalette()){
+ if (!bGrayScale){
+ info_ptr->valid |= PNG_INFO_PLTE;
+ }
++#endif
+
+ int nc = GetClrImportant();
+ if (nc==0) nc = GetNumColors();
+@@ -468,20 +693,34 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ if (info.bAlphaPaletteEnabled){
+ for(WORD ip=0; ip<nc;ip++)
+ trans[ip]=GetPaletteColor((BYTE)ip).rgbReserved;
++#if PNG_LIBPNG_VER <= 10499
+ info_ptr->num_trans = (WORD)nc;
+ info_ptr->valid |= PNG_INFO_tRNS;
++#endif
++#if PNG_LIBPNG_VER > 10499
++ png_set_tRNS(png_ptr,info_ptr,(png_bytep)trans,nc,NULL);
++#else
+ #if PNG_LIBPNG_VER > 10399
+ info_ptr->trans_alpha = trans;
+ #else
+ info_ptr->trans = trans;
+ #endif
++#endif
+ }
+
+ // copy the palette colors
++#if PNG_LIBPNG_VER > 10499
++ _palette = new png_color[nc];
++ for (int i=0; i<nc; i++)
++ GetPaletteColor(i, &_palette[i].red, &_palette[i].green, &_palette[i].blue);
++
++ png_set_PLTE(png_ptr,info_ptr,_palette,nc);
++#else
+ info_ptr->palette = new png_color[nc];
+ info_ptr->num_palette = (png_uint_16) nc;
+ for (int i=0; i<nc; i++)
+ GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
++#endif
+ }
+
+ #if CXIMAGE_SUPPORT_ALPHA // <vho>
+@@ -495,8 +734,12 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ } } }
+ #endif // CXIMAGE_SUPPORT_ALPHA // <vho>
+
++#if PNG_LIBPNG_VER > 10499
++ int row_size = max(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
++#else
+ int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
+ info_ptr->rowbytes = row_size;
++#endif
+ BYTE *row_pointers = new BYTE[row_size];
+
+ /* write the file information */
+@@ -514,7 +757,11 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ if (AlphaIsValid()){
+ for (long ax=head.biWidth-1; ax>=0;ax--){
+ c = BlindGetPixelColor(ax,ay);
++#if PNG_LIBPNG_VER > 10499
++ int px = ax * _channels;
++#else
+ int px = ax * info_ptr->channels;
++#endif
+ if (!bGrayScale){
+ row_pointers[px++]=c.rgbRed;
+ row_pointers[px++]=c.rgbGreen;
+@@ -529,7 +776,11 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ #endif //CXIMAGE_SUPPORT_ALPHA // <vho>
+ {
+ iter.GetRow(row_pointers, row_size);
++#if PNG_LIBPNG_VER > 10499
++ if (_color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP
++#else
+ if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP
++#endif
+ RGBtoBGR(row_pointers, row_size);
+ png_write_row(png_ptr, row_pointers);
+ }
+@@ -546,9 +797,14 @@ bool CxImagePNG::Encode(CxFile *hFile)
+ png_write_end(png_ptr, info_ptr);
+
+ /* if you malloced the palette, free it here */
++#if PNG_LIBPNG_VER > 10499
++ if (_palette){
++ delete [] (_palette);
++#else
+ if (info_ptr->palette){
+ delete [] (info_ptr->palette);
+ info_ptr->palette = NULL;
++#endif
+ }
+
+ /* clean up after the write, and free any memory allocated */
+--- a/lib/cximage-6.0/CxImage/ximapng.h
++++ b/lib/cximage-6.0/CxImage/ximapng.h
+@@ -69,8 +69,13 @@ class CxImagePNG: public CxImage
+
+ static void PNGAPI user_error_fn(png_structp png_ptr,png_const_charp error_msg)
+ {
++#if PNG_LIBPNG_VER > 10499
++ strncpy((char*)png_get_error_ptr(png_ptr),error_msg,255);
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ strncpy((char*)png_ptr->error_ptr,error_msg,255);
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+ };
+
diff --git a/media-tv/xbmc/files/xbmc-11.0-no-exec-stack.patch b/media-tv/xbmc/files/xbmc-11.0-no-exec-stack.patch
new file mode 100644
index 00000000..35ff747d
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-11.0-no-exec-stack.patch
@@ -0,0 +1,30 @@
+http://trac.xbmc.org/ticket/12735
+
+merged upstream already
+
+From f0e33eefa4b5d46f26811db2f5e943dcd7f2870e Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Thu, 1 Mar 2012 00:04:49 -0500
+Subject: [PATCH] mark stack as non-executable
+
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ xbmc/utils/fastmemcpy-arm.S | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/xbmc/utils/fastmemcpy-arm.S b/xbmc/utils/fastmemcpy-arm.S
+index 0e810a7..3d77c68 100644
+--- a/xbmc/utils/fastmemcpy-arm.S
++++ b/xbmc/utils/fastmemcpy-arm.S
+@@ -527,3 +527,8 @@ copy_last_3_and_return:
+
+ #endif /* __ARM_ARCH__ < 7 */
+ #endif
++
++#if defined(__linux__) && defined(__ELF__)
++/* we don't need an executable stack */
++.section .note.GNU-stack,"",%progbits
++#endif
+--
+1.7.8.4
+
diff --git a/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-fix-plt-trn-get.patch b/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-fix-plt-trn-get.patch
new file mode 100644
index 00000000..7e6ce676
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-fix-plt-trn-get.patch
@@ -0,0 +1,51 @@
+
+Update libpng 1.5 patch: check return values of png_get_PLTE() and
+png_get_tRNS() before using the values to avoid using uninitialized values.
+
+--- a/lib/cximage-6.0/CxImage/ximapng.cpp
++++ b/lib/cximage-6.0/CxImage/ximapng.cpp
+@@ -178,12 +178,14 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ int _num_palette;
+ png_colorp _palette;
+ #if PNG_LIBPNG_VER > 10399
+- png_get_PLTE(png_ptr,info_ptr,&_palette,&_num_palette);
++ png_uint_32 _palette_ret;
++ _palette_ret = png_get_PLTE(png_ptr,info_ptr,&_palette,&_num_palette);
++ if (_palette_ret && _num_palette>0){
+ #else
+ _num_palette=info_ptr->num_palette;
+ _palette=info_ptr->palette;
+-#endif
+ if (_num_palette>0){
++#endif
+ SetPalette((rgb_color*)_palette,_num_palette);
+ SetClrImportant(_num_palette);
+ } else if (_bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
+@@ -199,11 +201,13 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ int _num_trans;
+ png_color_16p _trans_color;
+ #if PNG_LIBPNG_VER > 10399
+- png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color);
++ png_uint_32 _trans_ret;
++ _trans_ret = png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color);
++ if (_trans_ret && _num_trans!=0){ //palette transparency
+ #else
+ _num_trans=info_ptr->num_trans;
+-#endif
+ if (_num_trans!=0){ //palette transparency
++#endif
+ if (_num_trans==1){
+ if (_color_type == PNG_COLOR_TYPE_PALETTE){
+ #if PNG_LIBPNG_VER > 10399
+@@ -219,7 +223,11 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ #endif
+ }
+ }
++#if PNG_LIBPNG_VER > 10399
++ if (_num_trans>1 && _trans_alpha!=NULL){
++#else
+ if (_num_trans>1){
++#endif
+ RGBQUAD* pal=GetPalette();
+ if (pal){
+ DWORD ip;
diff --git a/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-headers.patch b/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-headers.patch
new file mode 100644
index 00000000..4648f9fd
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5-headers.patch
@@ -0,0 +1,12 @@
+diff --git a/tools/TexturePacker/XBTFWriter.cpp b/tools/TexturePacker/XBTFWriter.cpp
+index 78b47fe..2e75d96 100644
+--- a/tools/TexturePacker/XBTFWriter.cpp
++++ b/tools/TexturePacker/XBTFWriter.cpp
+@@ -22,6 +22,7 @@
+ #include "XBTFWriter.h"
+ #define __STDC_FORMAT_MACROS
+ #include <inttypes.h>
++#include <unistd.h> /* for unlink() prototype */
+ #include "guilib/XBTF.h"
+ #include "utils/EndianSwap.h"
+ #if !defined(__APPLE__) && !defined(__FreeBSD__)
diff --git a/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5.patch b/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5.patch
new file mode 100644
index 00000000..da331d2b
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-11.0_beta1-libpng-1.5.patch
@@ -0,0 +1,596 @@
+fix building with newer libpng. patch by Ian Stakenvicius.
+
+https://bugs.gentoo.org/380127
+
+--- a/xbmc/lib/cximage-6.0/CxImage/ximapng.h
++++ b/xbmc/lib/cximage-6.0/CxImage/ximapng.h
+@@ -69,8 +69,13 @@
+
+ static void PNGAPI user_error_fn(png_structp png_ptr,png_const_charp error_msg)
+ {
++#if PNG_LIBPNG_VER > 10399
++ strncpy((char*)png_get_error_ptr(png_ptr),error_msg,255);
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ strncpy((char*)png_ptr->error_ptr,error_msg,255);
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+ };
+
+--- a/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp
++++ b/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp
+@@ -15,7 +15,11 @@
+ void CxImagePNG::ima_png_error(png_struct *png_ptr, char *message)
+ {
+ strcpy(info.szLastError,message);
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+ ////////////////////////////////////////////////////////////////////////////////
+ #if CXIMAGE_SUPPORT_DECODE
+@@ -62,7 +66,11 @@
+ /* Set error handling if you are using the setjmp/longjmp method (this is
+ * the normal method of doing things with libpng). REQUIRED unless you
+ * set up your own error handlers in the png_create_read_struct() earlier. */
++#if PNG_LIBPNG_VER > 10399
++ if (setjmp(png_jmpbuf(png_ptr))) {
++#else
+ if (setjmp(png_ptr->jmpbuf)) {
++#endif
+ /* Free all of the memory associated with the png_ptr and info_ptr */
+ delete [] row_pointers;
+ png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
+@@ -70,16 +78,35 @@
+ /* read the file information */
+ png_read_info(png_ptr, info_ptr);
+
++ png_uint_32 _width,_height;
++ int _bit_depth,_color_type,_interlace_type,_compression_type,_filter_type;
++#if PNG_LIBPNG_VER > 10399
++ png_get_IHDR(png_ptr,info_ptr,&_width,&_height,&_bit_depth,&_color_type,
++ &_interlace_type,&_compression_type,&_filter_type);
++#else
++ _width=info_ptr->width;
++ _height=info_ptr->height;
++ _bit_depth=info_ptr->bit_depth;
++ _color_type=info_ptr->color_type;
++ _interlace_type=info_ptr->interlace_type;
++ _compression_type=info_ptr->compression_type;
++ _filter_type=info_ptr->filter_type;
++#endif
++
+ if (info.nEscape == -1){
+- head.biWidth = info_ptr->width;
+- head.biHeight= info_ptr->height;
++ head.biWidth = _width;
++ head.biHeight= _height;
+ info.dwType = CXIMAGE_FORMAT_PNG;
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ /* calculate new number of channels */
+ int channels=0;
+- switch(info_ptr->color_type){
++ switch(_color_type){
+ case PNG_COLOR_TYPE_GRAY:
+ case PNG_COLOR_TYPE_PALETTE:
+ channels = 1;
+@@ -101,71 +128,108 @@
+ break;
+ default:
+ strcpy(info.szLastError,"unknown PNG color type");
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ //find the right pixel depth used for cximage
++#if PNG_LIBPNG_VER > 10399
++ int pixel_depth = _bit_depth * png_get_channels(png_ptr,info_ptr);
++#else
+ int pixel_depth = info_ptr->pixel_depth;
++#endif
+ if (channels == 1 && pixel_depth>8) pixel_depth=8;
+ if (channels == 2) pixel_depth=8;
+ if (channels >= 3) pixel_depth=24;
+
+- if (!Create(info_ptr->width, info_ptr->height, pixel_depth, CXIMAGE_FORMAT_PNG)){
++ if (!Create(_width, _height, pixel_depth, CXIMAGE_FORMAT_PNG)){
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
+ longjmp(png_ptr->jmpbuf, 1);
++#endif
+ }
+
+ /* get metrics */
+- switch (info_ptr->phys_unit_type)
++ png_uint_32 _x_pixels_per_unit,_y_pixels_per_unit;
++ int _phys_unit_type;
++#if PNG_LIBPNG_VER > 10399
++ png_get_pHYs(png_ptr,info_ptr,&_x_pixels_per_unit,&_y_pixels_per_unit,&_phys_unit_type);
++#else
++ _x_pixels_per_unit=info_ptr->x_pixels_per_unit;
++ _y_pixels_per_unit=info_ptr->y_pixels_per_unit;
++ _phys_unit_type=info_ptr->phys_unit_type;
++#endif
++ switch (_phys_unit_type)
+ {
+ case PNG_RESOLUTION_UNKNOWN:
+- SetXDPI(info_ptr->x_pixels_per_unit);
+- SetYDPI(info_ptr->y_pixels_per_unit);
++ SetXDPI(_x_pixels_per_unit);
++ SetYDPI(_y_pixels_per_unit);
+ break;
+ case PNG_RESOLUTION_METER:
+- SetXDPI((long)floor(info_ptr->x_pixels_per_unit * 254.0 / 10000.0 + 0.5));
+- SetYDPI((long)floor(info_ptr->y_pixels_per_unit * 254.0 / 10000.0 + 0.5));
++ SetXDPI((long)floor(_x_pixels_per_unit * 254.0 / 10000.0 + 0.5));
++ SetYDPI((long)floor(_y_pixels_per_unit * 254.0 / 10000.0 + 0.5));
+ break;
+ }
+
+- if (info_ptr->num_palette>0){
+- SetPalette((rgb_color*)info_ptr->palette,info_ptr->num_palette);
+- SetClrImportant(info_ptr->num_palette);
+- } else if (info_ptr->bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
++ int _num_palette;
++ png_colorp _palette;
++#if PNG_LIBPNG_VER > 10399
++ png_get_PLTE(png_ptr,info_ptr,&_palette,&_num_palette);
++#else
++ _num_palette=info_ptr->num_palette;
++ _palette=info_ptr->palette;
++#endif
++ if (_num_palette>0){
++ SetPalette((rgb_color*)_palette,_num_palette);
++ SetClrImportant(_num_palette);
++ } else if (_bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
+ SetPaletteColor(0,0,0,0);
+ SetPaletteColor(1,85,85,85);
+ SetPaletteColor(2,170,170,170);
+ SetPaletteColor(3,255,255,255);
+ } else SetGrayPalette(); //<DP> needed for grayscale PNGs
+
+- int nshift = max(0,(info_ptr->bit_depth>>3)-1)<<3;
++ int nshift = max(0,(_bit_depth>>3)-1)<<3;
+
+- if (info_ptr->num_trans!=0){ //palette transparency
+- if (info_ptr->num_trans==1){
+- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE){
++ png_bytep _trans_alpha;
++ int _num_trans;
++ png_color_16p _trans_color;
++#if PNG_LIBPNG_VER > 10399
++ png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color);
++#else
++ _num_trans=info_ptr->num_trans;
++#endif
++ if (_num_trans!=0){ //palette transparency
++ if (_num_trans==1){
++ if (_color_type == PNG_COLOR_TYPE_PALETTE){
+ #if PNG_LIBPNG_VER > 10399
+- info.nBkgndIndex = info_ptr->trans_color.index;
++ info.nBkgndIndex = _trans_color->index;
+ #else
+ info.nBkgndIndex = info_ptr->trans_values.index;
+ #endif
+ } else{
+ #if PNG_LIBPNG_VER > 10399
+- info.nBkgndIndex = info_ptr->trans_color.gray>>nshift;
++ info.nBkgndIndex = _trans_color->gray>>nshift;
+ #else
+ info.nBkgndIndex = info_ptr->trans_values.gray>>nshift;
+ #endif
+ }
+ }
+- if (info_ptr->num_trans>1){
++ if (_num_trans>1){
+ RGBQUAD* pal=GetPalette();
+ if (pal){
+ DWORD ip;
+- for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
++ for (ip=0;ip<min(head.biClrUsed,(unsigned long)_num_trans);ip++)
+ #if PNG_LIBPNG_VER > 10399
+- pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
++ pal[ip].rgbReserved=_trans_alpha[ip];
+ #else
+ pal[ip].rgbReserved=info_ptr->trans[ip];
+ #endif
+- for (ip=info_ptr->num_trans;ip<head.biClrUsed;ip++){
++ for (ip=_num_trans;ip<head.biClrUsed;ip++){
+ pal[ip].rgbReserved=255;
+ }
+ info.bAlphaPaletteEnabled=true;
+@@ -174,14 +238,12 @@
+ }
+
+ if (channels == 3){ //check RGB binary transparency
+- png_bytep trans;
+- int num_trans;
+- png_color_16 *image_background;
+- if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &image_background)){
+-#if PNG_LIBPNG_VER > 10399
+- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_color.red>>nshift);
+- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_color.green>>nshift);
+- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_color.blue>>nshift);
++ /* seems unnecessary to call again, but the conditional must be important so... */
++ if (png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color)){
++#if PNG_LIBPNG_VER > 10399
++ info.nBkgndColor.rgbRed = (BYTE)(_trans_color->red>>nshift);
++ info.nBkgndColor.rgbGreen = (BYTE)(_trans_color->green>>nshift);
++ info.nBkgndColor.rgbBlue = (BYTE)(_trans_color->blue>>nshift);
+ #else
+ info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_values.red>>nshift);
+ info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_values.green>>nshift);
+@@ -202,15 +264,24 @@
+ }
+
+ // <vho> - flip the RGB pixels to BGR (or RGBA to BGRA)
+- if (info_ptr->color_type & PNG_COLOR_MASK_COLOR){
++ if (_color_type & PNG_COLOR_MASK_COLOR){
+ png_set_bgr(png_ptr);
+ }
+
+ // <vho> - handle cancel
+- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
++ if (info.nEscape)
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
++ longjmp(png_ptr->jmpbuf, 1);
++#endif
+
+ // row_bytes is the width x number of channels x (bit-depth / 8)
++#if PNG_LIBPNG_VER > 10399
++ row_pointers = new BYTE[png_get_rowbytes(png_ptr,info_ptr) + 8];
++#else
+ row_pointers = new BYTE[info_ptr->rowbytes + 8];
++#endif
+
+ // turn on interlace handling
+ int number_passes = png_set_interlace_handling(png_ptr);
+@@ -221,8 +292,12 @@
+ SetCodecOption(0);
+ }
+
+- int chan_offset = info_ptr->bit_depth >> 3;
++ int chan_offset = _bit_depth >> 3;
++#if PNG_LIBPNG_VER > 10399
++ int pixel_offset = (_bit_depth * png_get_channels(png_ptr,info_ptr)) >> 3;
++#else
+ int pixel_offset = info_ptr->pixel_depth >> 3;
++#endif
+
+ for (int pass=0; pass < number_passes; pass++) {
+ iter.Upset();
+@@ -230,7 +305,12 @@
+ do {
+
+ // <vho> - handle cancel
+- if (info.nEscape) longjmp(png_ptr->jmpbuf, 1);
++ if (info.nEscape)
++#if PNG_LIBPNG_VER > 10399
++ longjmp(png_jmpbuf(png_ptr), 1);
++#else
++ longjmp(png_ptr->jmpbuf, 1);
++#endif
+
+ #if CXIMAGE_SUPPORT_ALPHA // <vho>
+ if (AlphaIsValid()) {
+@@ -241,7 +321,7 @@
+ BYTE* prow= iter.GetRow(ay);
+
+ //recover data from previous scan
+- if (info_ptr->interlace_type && pass>0 && pass!=7){
++ if (_interlace_type && pass>0 && pass!=7){
+ for(ax=0;ax<head.biWidth;ax++){
+ long px = ax * pixel_offset;
+ if (channels == 2){
+@@ -278,10 +358,14 @@
+ #endif // CXIMAGE_SUPPORT_ALPHA // vho
+ {
+ //recover data from previous scan
+- if (info_ptr->interlace_type && pass>0){
++ if (_interlace_type && pass>0){
++#if PNG_LIBPNG_VER > 10399
++ iter.GetRow(row_pointers, png_get_rowbytes(png_ptr,info_ptr));
++#else
+ iter.GetRow(row_pointers, info_ptr->rowbytes);
++#endif
+ //re-expand buffer for images with bit depth > 8
+- if (info_ptr->bit_depth > 8){
++ if (_bit_depth > 8){
+ for(long ax=(head.biWidth*channels-1);ax>=0;ax--)
+ row_pointers[ax*chan_offset] = row_pointers[ax];
+ }
+@@ -291,15 +375,19 @@
+ png_read_row(png_ptr, row_pointers, NULL);
+
+ //shrink 16 bit depth images down to 8 bits
+- if (info_ptr->bit_depth > 8){
++ if (_bit_depth > 8){
+ for(long ax=0;ax<(head.biWidth*channels);ax++)
+ row_pointers[ax] = row_pointers[ax*chan_offset];
+ }
+
+ //copy the pixels
++#if PNG_LIBPNG_VER > 10399
++ iter.SetRow(row_pointers, png_get_rowbytes(png_ptr,info_ptr));
++#else
+ iter.SetRow(row_pointers, info_ptr->rowbytes);
++#endif
+ //<DP> expand 2 bpp images only in the last pass
+- if (info_ptr->bit_depth==2 && pass==(number_passes-1))
++ if (_bit_depth==2 && pass==(number_passes-1))
+ expand2to4bpp(iter.GetRow());
+
+ //go on
+@@ -361,9 +449,13 @@
+ /* Set error handling. REQUIRED if you aren't supplying your own
+ * error hadnling functions in the png_create_write_struct() call.
+ */
++#if PNG_LIBPNG_VER > 10399
++ if (setjmp(png_jmpbuf(png_ptr))){
++#else
+ if (setjmp(png_ptr->jmpbuf)){
+ /* If we get here, we had a problem reading the file */
+ if (info_ptr->palette) free(info_ptr->palette);
++#endif
+ png_destroy_write_struct(&png_ptr, (png_infopp)&info_ptr);
+ cx_throw("Error saving PNG file");
+ }
+@@ -372,9 +464,23 @@
+ //png_init_io(png_ptr, hFile);
+
+ // use custom I/O functions
+- png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data);
++ png_set_write_fn(png_ptr,hFile,/*(png_rw_ptr)*/user_write_data,/*(png_flush_ptr)*/user_flush_data);
+
+ /* set the file information here */
++#if PNG_LIBPNG_VER > 10399
++ /* use variables to hold the values so it isnt necessary to png_get them later */
++ png_uint_32 _width,_height;
++ int _bit_depth,_color_type,_interlace_type,_compression_type,_filter_type;
++ png_byte _channels,_pixel_depth;
++
++ _width = GetWidth();
++ _height = GetHeight();
++ _pixel_depth = (BYTE)GetBpp();
++ _channels = (GetBpp()>8) ? (BYTE)3: (BYTE)1;
++ _bit_depth = (BYTE)(GetBpp()/_channels);
++ _compression_type = PNG_COMPRESSION_TYPE_DEFAULT;
++ _filter_type = PNG_FILTER_TYPE_DEFAULT;
++#else
+ info_ptr->width = GetWidth();
+ info_ptr->height = GetHeight();
+ info_ptr->pixel_depth = (BYTE)GetBpp();
+@@ -382,13 +488,22 @@
+ info_ptr->bit_depth = (BYTE)(GetBpp()/info_ptr->channels);
+ info_ptr->compression_type = info_ptr->filter_type = 0;
+ info_ptr->valid = 0;
++#endif
+
+ switch(GetCodecOption(CXIMAGE_FORMAT_PNG)){
+ case 1:
++#if PNG_LIBPNG_VER > 10399
++ _interlace_type = PNG_INTERLACE_ADAM7;
++#else
+ info_ptr->interlace_type = PNG_INTERLACE_ADAM7;
++#endif
+ break;
+ default:
++#if PNG_LIBPNG_VER > 10399
++ _interlace_type = PNG_INTERLACE_NONE;
++#else
+ info_ptr->interlace_type = PNG_INTERLACE_NONE;
++#endif
+ }
+
+ /* set compression level */
+@@ -398,22 +513,47 @@
+
+ if (GetNumColors()){
+ if (bGrayScale){
++#if PNG_LIBPNG_VER > 10399
++ _color_type = PNG_COLOR_TYPE_GRAY;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_GRAY;
++#endif
+ } else {
++#if PNG_LIBPNG_VER > 10399
++ _color_type = PNG_COLOR_TYPE_PALETTE;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
++#endif
+ }
+ } else {
++#if PNG_LIBPNG_VER > 10399
++ _color_type = PNG_COLOR_TYPE_RGB;
++#else
+ info_ptr->color_type = PNG_COLOR_TYPE_RGB;
++#endif
+ }
+ #if CXIMAGE_SUPPORT_ALPHA
+ if (AlphaIsValid()){
++#if PNG_LIBPNG_VER > 10399
++ _color_type |= PNG_COLOR_MASK_ALPHA;
++ _channels++;
++ _bit_depth = 8;
++ _pixel_depth += 8;
++#else
+ info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
+ info_ptr->channels++;
+ info_ptr->bit_depth = 8;
+ info_ptr->pixel_depth += 8;
++#endif
+ }
+ #endif
+
++#if PNG_LIBPNG_VER > 10399
++ /* set the header here, since we're done modifying these values */
++ png_set_IHDR(png_ptr,info_ptr,_width,_height,_bit_depth,_color_type,_interlace_type,
++ _compression_type,_filter_type);
++#endif
++
+ /* set background */
+ png_color_16 image_background={ 0, 255, 255, 255, 0 };
+ RGBQUAD tc = GetTransColor();
+@@ -427,22 +567,24 @@
+ /* set metrics */
+ png_set_pHYs(png_ptr, info_ptr, head.biXPelsPerMeter, head.biYPelsPerMeter, PNG_RESOLUTION_METER);
+
++#if PNG_LIBPNG_VER <= 10399
+ png_set_IHDR(png_ptr, info_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth,
+ info_ptr->color_type, info_ptr->interlace_type,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
++#endif
+
+ //<DP> simple transparency
+ if (info.nBkgndIndex >= 0){
+- info_ptr->num_trans = 1;
+- info_ptr->valid |= PNG_INFO_tRNS;
+ #if PNG_LIBPNG_VER > 10399
+- info_ptr->trans_alpha = trans;
+- info_ptr->trans_color.index = (BYTE)info.nBkgndIndex;
+- info_ptr->trans_color.red = tc.rgbRed;
+- info_ptr->trans_color.green = tc.rgbGreen;
+- info_ptr->trans_color.blue = tc.rgbBlue;
+- info_ptr->trans_color.gray = info_ptr->trans_color.index;
++ png_color_16 _trans_color;
++ _trans_color.index = (BYTE)info.nBkgndIndex;
++ _trans_color.red = tc.rgbRed;
++ _trans_color.green = tc.rgbGreen;
++ _trans_color.blue = tc.rgbBlue;
++ _trans_color.gray = _trans_color.index;
+ #else
++ info_ptr->num_trans = 1;
++ info_ptr->valid |= PNG_INFO_tRNS;
+ info_ptr->trans = trans;
+ info_ptr->trans_values.index = (BYTE)info.nBkgndIndex;
+ info_ptr->trans_values.red = tc.rgbRed;
+@@ -454,34 +596,53 @@
+ // the transparency indexes start from 0 for non grayscale palette
+ if (!bGrayScale && head.biClrUsed && info.nBkgndIndex)
+ SwapIndex(0,(BYTE)info.nBkgndIndex);
++
++#if PNG_LIBPNG_VER > 10399
++ png_set_tRNS(png_ptr,info_ptr,(png_bytep)trans,1,&_trans_color);
++#endif
+ }
+
+ /* set the palette if there is one */
++#if PNG_LIBPNG_VER > 10399
++ png_colorp _palette;
++#endif
+ if (GetPalette()){
++#if PNG_LIBPNG_VER <= 10399
+ if (!bGrayScale){
+ info_ptr->valid |= PNG_INFO_PLTE;
+ }
++#endif
+
+ int nc = GetClrImportant();
+ if (nc==0) nc = GetNumColors();
+
++ // copy the palette colors
++#if PNG_LIBPNG_VER > 10399
++ _palette = new png_color[nc];
++#else
++ info_ptr->palette = new png_color[nc];
++ info_ptr->num_palette = (png_uint_16) nc;
++#endif
++ for (int i=0; i<nc; i++)
++#if PNG_LIBPNG_VER > 10399
++ GetPaletteColor(i, &_palette[i].red, &_palette[i].green, &_palette[i].blue);
++
++ png_set_PLTE(png_ptr,info_ptr,_palette,nc);
++#else
++ GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
++#endif
++
+ if (info.bAlphaPaletteEnabled){
+ for(WORD ip=0; ip<nc;ip++)
+ trans[ip]=GetPaletteColor((BYTE)ip).rgbReserved;
+- info_ptr->num_trans = (WORD)nc;
+- info_ptr->valid |= PNG_INFO_tRNS;
+ #if PNG_LIBPNG_VER > 10399
+- info_ptr->trans_alpha = trans;
++ png_set_tRNS(png_ptr,info_ptr,(png_bytep)trans,nc,NULL);
+ #else
++ info_ptr->num_trans = (WORD)nc;
++ info_ptr->valid |= PNG_INFO_tRNS;
+ info_ptr->trans = trans;
+ #endif
+ }
+-
+- // copy the palette colors
+- info_ptr->palette = new png_color[nc];
+- info_ptr->num_palette = (png_uint_16) nc;
+- for (int i=0; i<nc; i++)
+- GetPaletteColor(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
+ }
+
+ #if CXIMAGE_SUPPORT_ALPHA // <vho>
+@@ -495,8 +656,12 @@
+ } } }
+ #endif // CXIMAGE_SUPPORT_ALPHA // <vho>
+
++#if PNG_LIBPNG_VER > 10399
++ int row_size = max(info.dwEffWidth, (_width * _channels * _bit_depth / 8));
++#else
+ int row_size = max(info.dwEffWidth, info_ptr->width*info_ptr->channels*(info_ptr->bit_depth/8));
+ info_ptr->rowbytes = row_size;
++#endif
+ BYTE *row_pointers = new BYTE[row_size];
+
+ /* write the file information */
+@@ -514,7 +679,11 @@
+ if (AlphaIsValid()){
+ for (long ax=head.biWidth-1; ax>=0;ax--){
+ c = BlindGetPixelColor(ax,ay);
++#if PNG_LIBPNG_VER > 10399
++ int px = ax * _channels;
++#else
+ int px = ax * info_ptr->channels;
++#endif
+ if (!bGrayScale){
+ row_pointers[px++]=c.rgbRed;
+ row_pointers[px++]=c.rgbGreen;
+@@ -529,7 +698,11 @@
+ #endif //CXIMAGE_SUPPORT_ALPHA // <vho>
+ {
+ iter.GetRow(row_pointers, row_size);
++#if PNG_LIBPNG_VER > 10399
++ if (_color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP
++#else
+ if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) //HACK BY OP
++#endif
+ RGBtoBGR(row_pointers, row_size);
+ png_write_row(png_ptr, row_pointers);
+ }
+@@ -546,9 +719,14 @@
+ png_write_end(png_ptr, info_ptr);
+
+ /* if you malloced the palette, free it here */
++#if PNG_LIBPNG_VER > 10399
++ if (_palette){
++ delete [] (_palette);
++#else
+ if (info_ptr->palette){
+ delete [] (info_ptr->palette);
+ info_ptr->palette = NULL;
++#endif
+ }
+
+ /* clean up after the write, and free any memory allocated */
diff --git a/media-tv/xbmc/files/xbmc-9.11-TexturePacker-parallel-build.patch b/media-tv/xbmc/files/xbmc-9.11-TexturePacker-parallel-build.patch
new file mode 100644
index 00000000..f6bc030e
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9.11-TexturePacker-parallel-build.patch
@@ -0,0 +1,13 @@
+http://trac.xbmc.org/ticket/9275
+
+--- xbmc/Makefile.in
++++ xbmc/Makefile.in
+@@ -501,7 +501,7 @@ else
+ $(MAKE) -C tools/XBMCTex/
+ endif
+
+-tools/TexturePacker/TexturePacker:
++tools/TexturePacker/TexturePacker: guilib/guilib.a xbmc/lib/libsquish/libsquish-@ARCH@.a
+ $(MAKE) -C tools/TexturePacker/
+
+ install-bin: xbmc.bin # developement convenience target
diff --git a/media-tv/xbmc/files/xbmc-9.11-jpeg-speedup.patch b/media-tv/xbmc/files/xbmc-9.11-jpeg-speedup.patch
new file mode 100644
index 00000000..63cadbf5
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9.11-jpeg-speedup.patch
@@ -0,0 +1,18 @@
+fix from upstream
+http://bugs.gentoo.org/300909
+
+r26689 | jmarshallnz | 2010-01-11 14:30:08 -0500 (Mon, 11 Jan 2010) | 2 lines
+fixed: Ticket #7810 - high cpu load during loading of images with libjpeg7, thanks to akawaka.
+
+Index: xbmc/lib/cximage-6.0/CxImage/ximajpg.cpp
+===================================================================
+--- xbmc/lib/cximage-6.0/CxImage/ximajpg.cpp (revision 26688)
++++ xbmc/lib/cximage-6.0/CxImage/ximajpg.cpp (revision 26689)
+@@ -220,6 +220,7 @@ bool CxImageJPG::Decode(CxFile * hFile)
+
+ // Set the scale <ignacio>
+ cinfo.scale_denom = GetJpegScale();
++ cinfo.scale_num = 1;
+
+ // Borrowed the idea from GIF implementation <ignacio>
+ if (info.nEscape == -1) {
diff --git a/media-tv/xbmc/files/xbmc-9.11-libpng14.patch b/media-tv/xbmc/files/xbmc-9.11-libpng14.patch
new file mode 100644
index 00000000..b5af087e
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9.11-libpng14.patch
@@ -0,0 +1,92 @@
+http://bugs.gentoo.org/319113
+http://repos.archlinux.org/wsvn/community/xbmc/trunk/libpng14.patch
+
+diff -Nur xbmc-9.11.orig/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp xbmc-9.11/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp
+--- xbmc-9.11.orig/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp 2008-07-18 23:40:53.000000000 +0300
++++ xbmc-9.11/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp 2010-01-20 21:55:11.000000000 +0200
+@@ -142,9 +142,9 @@
+ if (info_ptr->num_trans!=0){ //palette transparency
+ if (info_ptr->num_trans==1){
+ if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE){
+- info.nBkgndIndex = info_ptr->trans_values.index;
++ info.nBkgndIndex = info_ptr->trans_color.index;
+ } else{
+- info.nBkgndIndex = info_ptr->trans_values.gray>>nshift;
++ info.nBkgndIndex = info_ptr->trans_color.gray>>nshift;
+ }
+ }
+ if (info_ptr->num_trans>1){
+@@ -152,7 +152,7 @@
+ if (pal){
+ DWORD ip;
+ for (ip=0;ip<min(head.biClrUsed,(unsigned long)info_ptr->num_trans);ip++)
+- pal[ip].rgbReserved=info_ptr->trans[ip];
++ pal[ip].rgbReserved=info_ptr->trans_alpha[ip];
+ for (ip=info_ptr->num_trans;ip<head.biClrUsed;ip++){
+ pal[ip].rgbReserved=255;
+ }
+@@ -166,9 +166,9 @@
+ int num_trans;
+ png_color_16 *image_background;
+ if (png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, &image_background)){
+- info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_values.red>>nshift);
+- info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_values.green>>nshift);
+- info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_values.blue>>nshift);
++ info.nBkgndColor.rgbRed = (BYTE)(info_ptr->trans_color.red>>nshift);
++ info.nBkgndColor.rgbGreen = (BYTE)(info_ptr->trans_color.green>>nshift);
++ info.nBkgndColor.rgbBlue = (BYTE)(info_ptr->trans_color.blue>>nshift);
+ info.nBkgndColor.rgbReserved = 0;
+ info.nBkgndIndex = 0;
+ }
+@@ -417,12 +417,12 @@
+ if (info.nBkgndIndex >= 0){
+ info_ptr->num_trans = 1;
+ info_ptr->valid |= PNG_INFO_tRNS;
+- info_ptr->trans = trans;
+- info_ptr->trans_values.index = (BYTE)info.nBkgndIndex;
+- info_ptr->trans_values.red = tc.rgbRed;
+- info_ptr->trans_values.green = tc.rgbGreen;
+- info_ptr->trans_values.blue = tc.rgbBlue;
+- info_ptr->trans_values.gray = info_ptr->trans_values.index;
++ info_ptr->trans_alpha = trans;
++ info_ptr->trans_color.index = (BYTE)info.nBkgndIndex;
++ info_ptr->trans_color.red = tc.rgbRed;
++ info_ptr->trans_color.green = tc.rgbGreen;
++ info_ptr->trans_color.blue = tc.rgbBlue;
++ info_ptr->trans_color.gray = info_ptr->trans_color.index;
+
+ // the transparency indexes start from 0 for non grayscale palette
+ if (!bGrayScale && head.biClrUsed && info.nBkgndIndex)
+@@ -443,7 +443,7 @@
+ trans[ip]=GetPaletteColor((BYTE)ip).rgbReserved;
+ info_ptr->num_trans = (WORD)nc;
+ info_ptr->valid |= PNG_INFO_tRNS;
+- info_ptr->trans = trans;
++ info_ptr->trans_alpha = trans;
+ }
+
+ // copy the palette colors
+diff -Nur xbmc-9.11.orig/xbmc/screensavers/rsxs-0.9/src/pngimage.cc xbmc-9.11/xbmc/screensavers/rsxs-0.9/src/pngimage.cc
+--- xbmc-9.11.orig/xbmc/screensavers/rsxs-0.9/src/pngimage.cc 2008-07-30 23:35:38.000000000 +0300
++++ xbmc-9.11/xbmc/screensavers/rsxs-0.9/src/pngimage.cc 2010-01-20 22:21:01.000000000 +0200
+@@ -65,7 +65,7 @@
+ (png_get_color_type(png, pngInfo) == PNG_COLOR_TYPE_GRAY) &&
+ png_get_bit_depth(png, pngInfo) < 8
+ )
+- png_set_gray_1_2_4_to_8(png);
++ png_set_expand_gray_1_2_4_to_8(png);
+ if (png_get_valid(png, pngInfo, PNG_INFO_tRNS))
+ png_set_tRNS_to_alpha(png);
+ if (fullColor)
+diff -Nur xbmc-9.11.orig/xbmc/visualizations/Goom/goom2k4-0/src/pngload.c xbmc-9.11/xbmc/visualizations/Goom/goom2k4-0/src/pngload.c
+--- xbmc-9.11.orig/xbmc/visualizations/Goom/goom2k4-0/src/pngload.c 2008-08-04 05:05:51.000000000 +0300
++++ xbmc-9.11/xbmc/visualizations/Goom/goom2k4-0/src/pngload.c 2010-01-20 22:16:23.000000000 +0200
+@@ -94,7 +94,7 @@
+ png_set_palette_to_rgb (png_ptr);
+
+ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
+- png_set_gray_1_2_4_to_8 (png_ptr);
++ png_set_expand_gray_1_2_4_to_8 (png_ptr);
+ else if (color_type == PNG_COLOR_TYPE_GRAY ||
+ color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ png_set_gray_to_rgb (png_ptr);
diff --git a/media-tv/xbmc/files/xbmc-9.11-shader-upscalers.patch b/media-tv/xbmc/files/xbmc-9.11-shader-upscalers.patch
new file mode 100644
index 00000000..d4feaa47
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9.11-shader-upscalers.patch
@@ -0,0 +1,887 @@
+http://bugs.gentoo.org/306661
+
+backport shader based upscalers from svn trunk
+
+--- language/English/strings.xml
++++ language/English/strings.xml
+@@ -1554,16 +1554,17 @@
+ <string id="16304">Lanczos2</string>
+ <string id="16305">Lanczos3</string>
+ <string id="16306">Sinc8</string>
+-
+ <string id="16307">Bicubic (software)</string>
+ <string id="16308">Lanczos (software)</string>
+ <string id="16309">Sinc (software)</string>
+-
+ <string id="16310">(VDPAU)Temporal</string>
+ <string id="16311">(VDPAU)Temporal/Spatial</string>
+ <string id="16312">(VDPAU)Noise Reduction</string>
+ <string id="16313">(VDPAU)Sharpness</string>
+ <string id="16314">Inverse Telecine</string>
++ <string id="16315">Lanczos3 optimized</string>
++ <string id="16316">Auto</string>
++
+ <string id="17500">Display sleep timeout</string>
+
+ <string id="19000">Switch to channel</string>
+--- system/shaders/convolution-6x6.glsl
++++ system/shaders/convolution-6x6.glsl
+@@ -0,0 +1,69 @@
++uniform sampler2D img;
++uniform float stepx;
++uniform float stepy;
++
++#if (HAS_FLOAT_TEXTURE)
++uniform sampler1D kernelTex;
++
++vec3 weight(float pos)
++{
++ return texture1D(kernelTex, pos).rgb;
++}
++#else
++uniform sampler2D kernelTex;
++
++vec3 weight(float pos)
++{
++ //row 0 contains the high byte, row 1 contains the low byte
++ return ((texture2D(kernelTex, vec2(pos, 0.0)) * 256.0 + texture2D(kernelTex, vec2(pos, 1.0)))).rgb / 128.5 - 1.0;
++}
++#endif
++
++vec3 pixel(float xpos, float ypos)
++{
++ return texture2D(img, vec2(xpos, ypos)).rgb;
++}
++
++vec3 line (float ypos, vec3 xpos1, vec3 xpos2, vec3 linetaps1, vec3 linetaps2)
++{
++ vec3 pixels;
++
++ pixels = pixel(xpos1.r, ypos) * linetaps1.r;
++ pixels += pixel(xpos1.g, ypos) * linetaps2.r;
++ pixels += pixel(xpos1.b, ypos) * linetaps1.g;
++ pixels += pixel(xpos2.r, ypos) * linetaps2.g;
++ pixels += pixel(xpos2.g, ypos) * linetaps1.b;
++ pixels += pixel(xpos2.b, ypos) * linetaps2.b;
++
++ return pixels;
++}
++
++void main()
++{
++ float xf = fract(gl_TexCoord[0].x / stepx);
++ float yf = fract(gl_TexCoord[0].y / stepy);
++
++ vec3 linetaps1 = weight((1.0 - xf) / 2.0);
++ vec3 linetaps2 = weight((1.0 - xf) / 2.0 + 0.5);
++ vec3 columntaps1 = weight((1.0 - yf) / 2.0);
++ vec3 columntaps2 = weight((1.0 - yf) / 2.0 + 0.5);
++
++ vec3 xpos1 = vec3(
++ (-1.5 - xf) * stepx + gl_TexCoord[0].x,
++ (-0.5 - xf) * stepx + gl_TexCoord[0].x,
++ ( 0.5 - xf) * stepx + gl_TexCoord[0].x);
++ vec3 xpos2 = vec3(
++ ( 1.5 - xf) * stepx + gl_TexCoord[0].x,
++ ( 2.5 - xf) * stepx + gl_TexCoord[0].x,
++ ( 3.5 - xf) * stepx + gl_TexCoord[0].x);
++
++ gl_FragColor.rgb = line((-1.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r;
++ gl_FragColor.rgb += line((-0.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r;
++ gl_FragColor.rgb += line(( 0.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g;
++ gl_FragColor.rgb += line(( 1.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g;
++ gl_FragColor.rgb += line(( 2.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b;
++ gl_FragColor.rgb += line(( 3.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b;
++
++ gl_FragColor.a = gl_Color.a;
++}
++
+--- system/shaders/bicubic.glsl
++++ system/shaders/bicubic.glsl
+@@ -0,0 +1,47 @@
++uniform sampler2D img;
++uniform float stepx;
++uniform float stepy;
++uniform sampler2D kernelTex;
++
++vec4 cubicFilter(float xValue, vec4 c0, vec4 c1, vec4 c2, vec4 c3)
++{
++ vec4 h = texture2D(kernelTex, vec2(xValue, 0.5));
++ vec4 r = c0 * h.r;
++ r += c1 * h.g;
++ r += c2 * h.b;
++ r += c3 * h.a;
++ return r;
++}
++
++void main()
++{
++ vec2 f = vec2(gl_TexCoord[0].x / stepx , gl_TexCoord[0].y / stepy);
++ f = fract(f);
++ vec4 t0 = cubicFilter(f.x,
++ texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, -stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(0.0, -stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(stepx, -stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, -stepy)));
++
++ vec4 t1 = cubicFilter(f.x,
++ texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, 0.0)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(0.0, 0.0)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(stepx, 0.0)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, 0.0)));
++
++ vec4 t2 = cubicFilter(f.x,
++ texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(0.0, stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(stepx, stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, stepy)));
++
++ vec4 t3 = cubicFilter(f.x,
++ texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, 2.0*stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(0, 2.0*stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(stepx, 2.0*stepy)),
++ texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, 2.0*stepy)));
++
++ gl_FragColor = cubicFilter(f.y, t0, t1, t2, t3);
++ gl_FragColor.a = gl_Color.a;
++}
++
+--- system/shaders/convolution-4x4.glsl
++++ system/shaders/convolution-4x4.glsl
+@@ -0,0 +1,60 @@
++uniform sampler2D img;
++uniform float stepx;
++uniform float stepy;
++
++#if (HAS_FLOAT_TEXTURE)
++uniform sampler1D kernelTex;
++
++vec4 weight(float pos)
++{
++ return texture1D(kernelTex, pos);
++}
++#else
++uniform sampler2D kernelTex;
++
++vec4 weight(float pos)
++{
++ //row 0 contains the high byte, row 1 contains the low byte
++ return (texture2D(kernelTex, vec2(pos, 0.0)) * 256.0 + texture2D(kernelTex, vec2(pos, 1.0))) / 128.5 - 1.0;
++}
++#endif
++
++vec3 pixel(float xpos, float ypos)
++{
++ return texture2D(img, vec2(xpos, ypos)).rgb;
++}
++
++vec3 line (float ypos, vec4 xpos, vec4 linetaps)
++{
++ vec3 pixels;
++
++ pixels = pixel(xpos.r, ypos) * linetaps.r;
++ pixels += pixel(xpos.g, ypos) * linetaps.g;
++ pixels += pixel(xpos.b, ypos) * linetaps.b;
++ pixels += pixel(xpos.a, ypos) * linetaps.a;
++
++ return pixels;
++}
++
++void main()
++{
++ float xf = fract(gl_TexCoord[0].x / stepx);
++ float yf = fract(gl_TexCoord[0].y / stepy);
++
++ vec4 linetaps = weight(1.0 - xf);
++ vec4 columntaps = weight(1.0 - yf);
++
++ vec4 xpos = vec4(
++ (-0.5 - xf) * stepx + gl_TexCoord[0].x,
++ ( 0.5 - xf) * stepx + gl_TexCoord[0].x,
++ ( 1.5 - xf) * stepx + gl_TexCoord[0].x,
++ ( 2.5 - xf) * stepx + gl_TexCoord[0].x);
++
++ gl_FragColor.rgb = line((-0.5 - yf) * stepy + gl_TexCoord[0].y, xpos, linetaps) * columntaps.r;
++ gl_FragColor.rgb += line(( 0.5 - yf) * stepy + gl_TexCoord[0].y, xpos, linetaps) * columntaps.g;
++ gl_FragColor.rgb += line(( 1.5 - yf) * stepy + gl_TexCoord[0].y, xpos, linetaps) * columntaps.b;
++ gl_FragColor.rgb += line(( 2.5 - yf) * stepy + gl_TexCoord[0].y, xpos, linetaps) * columntaps.a;
++
++ gl_FragColor.a = gl_Color.a;
++}
++
+--- xbmc/settings/VideoSettings.h
++++ xbmc/settings/VideoSettings.h
+@@ -51,9 +51,10 @@
+ {
+ VS_SCALINGMETHOD_NEAREST=0,
+ VS_SCALINGMETHOD_LINEAR,
+-
++
+ VS_SCALINGMETHOD_CUBIC,
+ VS_SCALINGMETHOD_LANCZOS2,
++ VS_SCALINGMETHOD_LANCZOS3_FAST,
+ VS_SCALINGMETHOD_LANCZOS3,
+ VS_SCALINGMETHOD_SINC8,
+ VS_SCALINGMETHOD_NEDI,
+@@ -61,7 +62,9 @@
+ VS_SCALINGMETHOD_BICUBIC_SOFTWARE,
+ VS_SCALINGMETHOD_LANCZOS_SOFTWARE,
+ VS_SCALINGMETHOD_SINC_SOFTWARE,
+- VS_SCALINGMETHOD_VDPAU_HARDWARE
++ VS_SCALINGMETHOD_VDPAU_HARDWARE,
++
++ VS_SCALINGMETHOD_AUTO
+ };
+
+ class CVideoSettings
+--- xbmc/cores/VideoRenderers/VideoShaders/VideoFilterShader.cpp
++++ xbmc/cores/VideoRenderers/VideoShaders/VideoFilterShader.cpp
+@@ -21,6 +21,7 @@
+ #include "system.h"
+ #include "VideoFilterShader.h"
+ #include "utils/log.h"
++#include "ConvolutionKernels.h"
+
+ #include <string>
+ #include <math.h>
+@@ -63,60 +64,13 @@
+
+ BicubicFilterShader::BicubicFilterShader(float B, float C)
+ {
+- string shaderf =
+- "uniform sampler2D img;"
+- "uniform float stepx;"
+- "uniform float stepy;"
+- "uniform sampler2D kernelTex;"
+-
+- "vec4 cubicFilter(float xValue, vec4 c0, vec4 c1, vec4 c2, vec4 c3)"
+- "{"
+- " vec4 h = texture2D(kernelTex, vec2(xValue, 0.5));"
+- " vec4 r = c0 * h.r;"
+- " r += c1 * h.g;"
+- " r += c2 * h.b;"
+- " r += c3 * h.a;"
+- " return r;"
+- "}"
+- ""
+- "void main()"
+- "{"
+- "vec2 f = vec2(gl_TexCoord[0].x / stepx , gl_TexCoord[0].y / stepy);"
+- "f = fract(f);"
+- "vec4 t0 = cubicFilter(f.x,"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, -stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(0.0, -stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(stepx, -stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, -stepy)));"
+- ""
+- "vec4 t1 = cubicFilter(f.x,"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, 0.0)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(0.0, 0.0)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(stepx, 0.0)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, 0.0)));"
+- ""
+- "vec4 t2 = cubicFilter(f.x,"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(0.0, stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(stepx, stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, stepy)));"
+- ""
+- "vec4 t3 = cubicFilter(f.x,"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(-stepx, 2.0*stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(0, 2.0*stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(stepx, 2.0*stepy)),"
+- "texture2D(img, gl_TexCoord[0].xy + vec2(2.0*stepx, 2.0*stepy)));"
+-
+- "gl_FragColor = cubicFilter(f.y, t0, t1, t2, t3) ;"
+- "gl_FragColor.a = gl_Color.a;"
+- "}";
+- PixelShader()->SetSource(shaderf);
++ PixelShader()->LoadSource("bicubic.glsl");
+ m_kernelTex1 = 0;
+ m_B = B;
+ m_C = C;
+- if (B<=0)
++ if (B<0)
+ m_B=1.0f/3.0f;
+- if (C<=0)
++ if (C<0)
+ m_C=1.0f/3.0f;
+ }
+
+@@ -209,8 +163,8 @@
+ glBindTexture(GL_TEXTURE_2D, m_kernelTex1);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, size, 1, 0, GL_RGBA, GL_FLOAT, img);
+
+ glActiveTexture(GL_TEXTURE0);
+@@ -254,4 +208,110 @@
+ return val;
+ }
+
++ConvolutionFilterShader::ConvolutionFilterShader(ESCALINGMETHOD method)
++{
++ m_method = method;
++ m_kernelTex1 = 0;
++
++ string shadername;
++ string defines;
++
++ if (m_method == VS_SCALINGMETHOD_CUBIC ||
++ m_method == VS_SCALINGMETHOD_LANCZOS2 ||
++ m_method == VS_SCALINGMETHOD_LANCZOS3_FAST)
++ shadername = "convolution-4x4.glsl";
++ else if (m_method == VS_SCALINGMETHOD_LANCZOS3)
++ shadername = "convolution-6x6.glsl";
++
++ m_floattex = glewIsSupported("GL_ARB_texture_float");
++
++ if (m_floattex)
++ defines = "#define HAS_FLOAT_TEXTURE 1\n";
++ else
++ defines = "#define HAS_FLOAT_TEXTURE 0\n";
++
++ CLog::Log(LOGDEBUG, "GL: ConvolutionFilterShader: using %s defines: %s", shadername.c_str(), defines.c_str());
++ PixelShader()->LoadSource(shadername, defines);
++}
++
++void ConvolutionFilterShader::OnCompiledAndLinked()
++{
++ // obtain shader attribute handles on successfull compilation
++ m_hSourceTex = glGetUniformLocation(ProgramHandle(), "img");
++ m_hStepX = glGetUniformLocation(ProgramHandle(), "stepx");
++ m_hStepY = glGetUniformLocation(ProgramHandle(), "stepy");
++ m_hKernTex = glGetUniformLocation(ProgramHandle(), "kernelTex");
++
++ CConvolutionKernel kernel(m_method, 256);
++
++ if (m_kernelTex1)
++ {
++ glDeleteTextures(1, &m_kernelTex1);
++ m_kernelTex1 = 0;
++ }
++
++ glGenTextures(1, &m_kernelTex1);
++
++ if ((m_kernelTex1<=0))
++ {
++ CLog::Log(LOGERROR, "GL: ConvolutionFilterShader: Error creating kernel texture");
++ return;
++ }
++
++ glActiveTexture(GL_TEXTURE2);
++
++ //if float textures are supported, we can load the kernel as a 1d float texture
++ //if not, we load it as a 2d texture with 2 rows, where row 0 contains the high byte
++ //and row 1 contains the low byte, which can be converted in the shader
++ if (m_floattex)
++ {
++ glBindTexture(GL_TEXTURE_1D, m_kernelTex1);
++ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
++ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
++ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
++ glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
++ glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA16F_ARB, kernel.GetSize(), 0, GL_RGBA, GL_FLOAT, kernel.GetFloatPixels());
++ }
++ else
++ {
++ glBindTexture(GL_TEXTURE_2D, m_kernelTex1);
++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
++ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kernel.GetSize(), 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, kernel.GetIntFractPixels());
++ }
++
++ glActiveTexture(GL_TEXTURE0);
++
++ VerifyGLState();
++}
++
++bool ConvolutionFilterShader::OnEnabled()
++{
++ // set shader attributes once enabled
++ glActiveTexture(GL_TEXTURE2);
++
++ if (m_floattex)
++ glBindTexture(GL_TEXTURE_1D, m_kernelTex1);
++ else
++ glBindTexture(GL_TEXTURE_2D, m_kernelTex1);
++
++ glActiveTexture(GL_TEXTURE0);
++ glUniform1i(m_hSourceTex, m_sourceTexUnit);
++ glUniform1i(m_hKernTex, 2);
++ glUniform1f(m_hStepX, m_stepX);
++ glUniform1f(m_hStepY, m_stepY);
++ VerifyGLState();
++ return true;
++}
++
++void ConvolutionFilterShader::Free()
++{
++ if (m_kernelTex1)
++ glDeleteTextures(1, &m_kernelTex1);
++ m_kernelTex1 = 0;
++ BaseVideoFilterShader::Free();
++}
++
+ #endif
+--- xbmc/cores/VideoRenderers/VideoShaders/ConvolutionKernels.cpp
++++ xbmc/cores/VideoRenderers/VideoShaders/ConvolutionKernels.cpp
+@@ -0,0 +1,226 @@
++/*
++ * 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
++ *
++ */
++#ifdef _WIN32
++ #define _USE_MATH_DEFINES
++#endif
++
++#include "ConvolutionKernels.h"
++#include "MathUtils.h"
++
++#define SINC(x) (sin(M_PI * (x)) / (M_PI * (x)))
++
++CConvolutionKernel::CConvolutionKernel(ESCALINGMETHOD method, int size)
++{
++ m_size = size;
++ m_floatpixels = new float[m_size * 4];
++
++ if (method == VS_SCALINGMETHOD_LANCZOS2)
++ Lanczos2();
++ else if (method == VS_SCALINGMETHOD_LANCZOS3_FAST)
++ Lanczos3Fast();
++ else if (method == VS_SCALINGMETHOD_LANCZOS3)
++ Lanczos3();
++ else if (method == VS_SCALINGMETHOD_CUBIC)
++ Bicubic(1.0 / 3.0, 1.0 / 3.0);
++
++ ToIntFract();
++}
++
++CConvolutionKernel::~CConvolutionKernel()
++{
++ delete [] m_floatpixels;
++ delete [] m_intfractpixels;
++}
++
++//generate a lanczos2 kernel which can be loaded with RGBA format
++//each value of RGBA has one tap, so a shader can load 4 taps with a single pixel lookup
++void CConvolutionKernel::Lanczos2()
++{
++ for (int i = 0; i < m_size; i++)
++ {
++ double x = (double)i / (double)m_size;
++
++ //generate taps
++ for (int j = 0; j < 4; j++)
++ m_floatpixels[i * 4 + j] = (float)LanczosWeight(x + (double)(j - 2), 2.0);
++
++ //any collection of 4 taps added together needs to be exactly 1.0
++ //for lanczos this is not always the case, so we take each collection of 4 taps
++ //and divide those taps by the sum of the taps
++ float weight = 0.0;
++ for (int j = 0; j < 4; j++)
++ weight += m_floatpixels[i * 4 + j];
++
++ for (int j = 0; j < 4; j++)
++ m_floatpixels[i * 4 + j] /= weight;
++ }
++}
++
++//generate a lanczos3 kernel which can be loaded with RGBA format
++//each value of RGBA has one tap, so a shader can load 4 taps with a single pixel lookup
++//the two outer lobes of the lanczos3 kernel are added to the two lobes one step to the middle
++//this basically looks the same as lanczos3, but the kernel only has 4 taps,
++//so it can use the 4x4 convolution shader which is twice as fast as the 6x6 one
++void CConvolutionKernel::Lanczos3Fast()
++{
++ for (int i = 0; i < m_size; i++)
++ {
++ double a = 3.0;
++ double x = (double)i / (double)m_size;
++
++ //generate taps
++ m_floatpixels[i * 4 + 0] = (float)(LanczosWeight(x - 2.0, a) + LanczosWeight(x - 3.0, a));
++ m_floatpixels[i * 4 + 1] = (float) LanczosWeight(x - 1.0, a);
++ m_floatpixels[i * 4 + 2] = (float) LanczosWeight(x , a);
++ m_floatpixels[i * 4 + 3] = (float)(LanczosWeight(x + 1.0, a) + LanczosWeight(x + 2.0, a));
++
++ //any collection of 4 taps added together needs to be exactly 1.0
++ //for lanczos this is not always the case, so we take each collection of 4 taps
++ //and divide those taps by the sum of the taps
++ float weight = 0.0;
++ for (int j = 0; j < 4; j++)
++ weight += m_floatpixels[i * 4 + j];
++
++ for (int j = 0; j < 4; j++)
++ m_floatpixels[i * 4 + j] /= weight;
++ }
++}
++
++//generate a lanczos3 kernel which can be loaded with RGBA format
++//each value of RGB has one tap, so a shader can load 3 taps with a single pixel lookup
++void CConvolutionKernel::Lanczos3()
++{
++ for (int i = 0; i < m_size; i++)
++ {
++ double x = (double)i / (double)m_size;
++
++ //generate taps
++ for (int j = 0; j < 3; j++)
++ m_floatpixels[i * 4 + j] = (float)LanczosWeight(x * 2.0 + (double)(j * 2 - 3), 3.0);
++
++ m_floatpixels[i * 4 + 3] = 0.0;
++ }
++
++ //any collection of 6 taps added together needs to be exactly 1.0
++ //for lanczos this is not always the case, so we take each collection of 6 taps
++ //and divide those taps by the sum of the taps
++ for (int i = 0; i < m_size / 2; i++)
++ {
++ float weight = 0.0;
++ for (int j = 0; j < 3; j++)
++ {
++ weight += m_floatpixels[i * 4 + j];
++ weight += m_floatpixels[(i + m_size / 2) * 4 + j];
++ }
++ for (int j = 0; j < 3; j++)
++ {
++ m_floatpixels[i * 4 + j] /= weight;
++ m_floatpixels[(i + m_size / 2) * 4 + j] /= weight;
++ }
++ }
++}
++
++//generate a bicubic kernel which can be loaded with RGBA format
++//each value of RGBA has one tap, so a shader can load 4 taps with a single pixel lookup
++void CConvolutionKernel::Bicubic(double B, double C)
++{
++ for (int i = 0; i < m_size; i++)
++ {
++ double x = (double)i / (double)m_size;
++
++ //generate taps
++ for (int j = 0; j < 4; j++)
++ m_floatpixels[i * 4 + j] = (float)BicubicWeight(x + (double)(j - 2), B, C);
++ }
++}
++
++double CConvolutionKernel::LanczosWeight(double x, double radius)
++{
++ double ax = fabs(x);
++
++ if (ax == 0.0)
++ return 1.0;
++ else if (ax < radius)
++ return SINC(ax) * SINC(ax / radius);
++ else
++ return 0.0;
++}
++
++double CConvolutionKernel::BicubicWeight(double x, double B, double C)
++{
++ double ax = fabs(x);
++
++ if (ax<1.0)
++ {
++ return ((12 - 9*B - 6*C) * ax * ax * ax +
++ (-18 + 12*B + 6*C) * ax * ax +
++ (6 - 2*B))/6;
++ }
++ else if (ax<2.0)
++ {
++ return ((-B - 6*C) * ax * ax * ax +
++ (6*B + 30*C) * ax * ax + (-12*B - 48*C) *
++ ax + (8*B + 24*C)) / 6;
++ }
++ else
++ {
++ return 0.0;
++ }
++}
++
++
++//convert float to high byte/low byte, so the kernel can be loaded into an 8 bit texture
++//with height 2 and converted back to real float in the shader
++//it only works when the kernel texture uses nearest neighbour, but there's almost no difference
++//between that and linear interpolation
++void CConvolutionKernel::ToIntFract()
++{
++ m_intfractpixels = new uint8_t[m_size * 8];
++
++ for (int i = 0; i < m_size * 4; i++)
++ {
++ int value = MathUtils::round_int((m_floatpixels[i] + 1.0) / 2.0 * 65535.0);
++ if (value < 0)
++ value = 0;
++ else if (value > 65535)
++ value = 65535;
++
++ int integer = value / 256;
++ int fract = value % 256;
++
++ m_intfractpixels[i] = (uint8_t)integer;
++ m_intfractpixels[i + m_size * 4] = (uint8_t)fract;
++ }
++
++#if 0
++ for (int i = 0; i < 4; i++)
++ {
++ for (int j = 0; j < m_size; j++)
++ {
++ printf("%i %f %f\n",
++ i * m_size + j,
++ ((double)m_intfractpixels[j * 4 + i] + (double)m_intfractpixels[j * 4 + i + m_size * 4] / 255.0) / 255.0 * 2.0 - 1.0,
++ m_floatpixels[j * 4 + i]);
++ }
++ }
++#endif
++}
++
+--- xbmc/cores/VideoRenderers/VideoShaders/VideoFilterShader.h
++++ xbmc/cores/VideoRenderers/VideoShaders/VideoFilterShader.h
+@@ -4,6 +4,7 @@
+ #ifdef HAS_GL
+
+ #include "../../../../guilib/Shader.h"
++#include "../../../settings/VideoSettings.h"
+
+ using namespace Shaders;
+
+@@ -35,7 +36,7 @@
+ class BicubicFilterShader : public BaseVideoFilterShader
+ {
+ public:
+- BicubicFilterShader(float B=0.0f, float C=0.0f);
++ BicubicFilterShader(float B=-1.0f, float C=-1.0f);
+ void OnCompiledAndLinked();
+ bool OnEnabled();
+ void Free();
+@@ -55,6 +56,25 @@
+ float m_C;
+ };
+
++ class ConvolutionFilterShader : public BaseVideoFilterShader
++ {
++ public:
++ ConvolutionFilterShader(ESCALINGMETHOD method);
++ void OnCompiledAndLinked();
++ bool OnEnabled();
++ void Free();
++
++ protected:
++ // kernel textures
++ GLuint m_kernelTex1;
++
++ // shader handles to kernel textures
++ GLint m_hKernTex;
++
++ ESCALINGMETHOD m_method;
++ bool m_floattex; //if float textures are supported
++ };
++
+ } // end namespace
+
+ #endif
+--- xbmc/cores/VideoRenderers/VideoShaders/ConvolutionKernels.h
++++ xbmc/cores/VideoRenderers/VideoShaders/ConvolutionKernels.h
+@@ -0,0 +1,55 @@
++/*
++ * 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 CONVOLUTIONKERNELS
++#define CONVOLUTIONKERNELS
++
++#include "system.h"
++#include "../../../settings/VideoSettings.h"
++
++class CConvolutionKernel
++{
++ public:
++ CConvolutionKernel(ESCALINGMETHOD method, int size);
++ ~CConvolutionKernel();
++
++ int GetSize() { return m_size; }
++ float* GetFloatPixels() { return m_floatpixels; }
++ uint8_t* GetIntFractPixels() { return m_intfractpixels; }
++
++ private:
++
++ void Lanczos2();
++ void Lanczos3Fast();
++ void Lanczos3();
++ void Bicubic(double B, double C);
++
++ double LanczosWeight(double x, double radius);
++ double BicubicWeight(double x, double B, double C);
++
++ void ToIntFract();
++
++ int m_size;
++ float* m_floatpixels;
++ uint8_t* m_intfractpixels;
++};
++
++#endif //CONVOLUTIONKERNELS
+--- xbmc/cores/VideoRenderers/VideoShaders/Makefile
++++ xbmc/cores/VideoRenderers/VideoShaders/Makefile
+@@ -1,5 +1,5 @@
+ INCLUDES=-I. -I.. -I../../ -I../../../ -I../../../linux -I../../../../guilib
+-SRCS=YUV2RGBShader.cpp VideoFilterShader.cpp
++SRCS=YUV2RGBShader.cpp VideoFilterShader.cpp ConvolutionKernels.cpp
+
+ LIB=VideoShaders.a
+
+--- xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
++++ xbmc/cores/VideoRenderers/LinuxRendererGL.cpp
+@@ -886,6 +886,19 @@
+
+ VerifyGLState();
+
++ if (m_scalingMethod == VS_SCALINGMETHOD_AUTO)
++ {
++ bool scaleSD = (int)m_sourceWidth < m_upscalingWidth && (int)m_sourceHeight < m_upscalingHeight &&
++ m_sourceHeight < 720 && m_sourceWidth < 1280;
++
++ if (Supports(VS_SCALINGMETHOD_VDPAU_HARDWARE))
++ m_scalingMethod = VS_SCALINGMETHOD_VDPAU_HARDWARE;
++ else if (Supports(VS_SCALINGMETHOD_LANCZOS3_FAST) && scaleSD)
++ m_scalingMethod = VS_SCALINGMETHOD_LANCZOS3_FAST;
++ else
++ m_scalingMethod = VS_SCALINGMETHOD_LINEAR;
++ }
++
+ switch (m_scalingMethod)
+ {
+ case VS_SCALINGMETHOD_NEAREST:
+@@ -898,13 +911,10 @@
+ m_renderQuality = RQ_SINGLEPASS;
+ return;
+
++ case VS_SCALINGMETHOD_LANCZOS2:
++ case VS_SCALINGMETHOD_LANCZOS3_FAST:
++ case VS_SCALINGMETHOD_LANCZOS3:
+ case VS_SCALINGMETHOD_CUBIC:
+- if(!glewIsSupported("GL_ARB_texture_float"))
+- {
+- CLog::Log(LOGERROR, "GL: hardware doesn't support GL_ARB_texture_float");
+- break;
+- }
+-
+ if (!m_fbo.Initialize())
+ {
+ CLog::Log(LOGERROR, "GL: Error initializing FBO");
+@@ -917,7 +927,7 @@
+ break;
+ }
+
+- m_pVideoFilterShader = new BicubicFilterShader(0.3f, 0.3f);
++ m_pVideoFilterShader = new ConvolutionFilterShader(m_scalingMethod);
+ if (!m_pVideoFilterShader->CompileAndLink())
+ {
+ CLog::Log(LOGERROR, "GL: Error compiling and linking video filter shader");
+@@ -928,8 +938,6 @@
+ m_renderQuality = RQ_MULTIPASS;
+ return;
+
+- case VS_SCALINGMETHOD_LANCZOS2:
+- case VS_SCALINGMETHOD_LANCZOS3:
+ case VS_SCALINGMETHOD_SINC8:
+ case VS_SCALINGMETHOD_NEDI:
+ CLog::Log(LOGERROR, "GL: TODO: This scaler has not yet been implemented");
+@@ -1895,16 +1903,19 @@
+ bool CLinuxRendererGL::Supports(ESCALINGMETHOD method)
+ {
+ if(method == VS_SCALINGMETHOD_NEAREST
+- || method == VS_SCALINGMETHOD_LINEAR)
++ || method == VS_SCALINGMETHOD_LINEAR
++ || method == VS_SCALINGMETHOD_AUTO)
+ return true;
+
+-
+- if(method == VS_SCALINGMETHOD_CUBIC
+- && glewIsSupported("GL_ARB_texture_float")
+- && glewIsSupported("GL_EXT_framebuffer_object")
+- && m_renderMethod == RENDER_GLSL)
+- return true;
+-
++ if(method == VS_SCALINGMETHOD_CUBIC
++ || method == VS_SCALINGMETHOD_LANCZOS2
++ || method == VS_SCALINGMETHOD_LANCZOS3_FAST
++ || method == VS_SCALINGMETHOD_LANCZOS3)
++ {
++ if (glewIsSupported("GL_EXT_framebuffer_object") && (m_renderMethod & RENDER_GLSL))
++ return true;
++ }
++
+ if (g_advancedSettings.m_videoHighQualityScaling != SOFTWARE_UPSCALING_DISABLED)
+ {
+ if(method == VS_SCALINGMETHOD_BICUBIC_SOFTWARE
+--- xbmc/GUIDialogVideoSettings.cpp
++++ xbmc/GUIDialogVideoSettings.cpp
+@@ -103,6 +103,7 @@
+ entries.push_back(make_pair(VS_SCALINGMETHOD_LINEAR , 16302));
+ entries.push_back(make_pair(VS_SCALINGMETHOD_CUBIC , 16303));
+ entries.push_back(make_pair(VS_SCALINGMETHOD_LANCZOS2 , 16304));
++ entries.push_back(make_pair(VS_SCALINGMETHOD_LANCZOS3_FAST , 16315));
+ entries.push_back(make_pair(VS_SCALINGMETHOD_LANCZOS3 , 16305));
+ entries.push_back(make_pair(VS_SCALINGMETHOD_SINC8 , 16306));
+ // entries.push_back(make_pair(VS_SCALINGMETHOD_NEDI , ?????));
+@@ -110,6 +111,7 @@
+ entries.push_back(make_pair(VS_SCALINGMETHOD_LANCZOS_SOFTWARE , 16308));
+ entries.push_back(make_pair(VS_SCALINGMETHOD_SINC_SOFTWARE , 16309));
+ entries.push_back(make_pair(VS_SCALINGMETHOD_VDPAU_HARDWARE , 13120));
++ entries.push_back(make_pair(VS_SCALINGMETHOD_AUTO , 16316));
+
+ /* remove unsupported methods */
+ for(vector<pair<int, int> >::iterator it = entries.begin(); it != entries.end();)
+--- xbmc/Settings.cpp
++++ xbmc/Settings.cpp
+@@ -772,7 +772,7 @@
+ GetInteger(pElement, "interlacemethod", interlaceMethod, VS_INTERLACEMETHOD_NONE, VS_INTERLACEMETHOD_NONE, VS_INTERLACEMETHOD_INVERSE_TELECINE);
+ m_stSettings.m_defaultVideoSettings.m_InterlaceMethod = (EINTERLACEMETHOD)interlaceMethod;
+ int scalingMethod;
+- GetInteger(pElement, "scalingmethod", scalingMethod, VS_SCALINGMETHOD_LINEAR, VS_SCALINGMETHOD_NEAREST, VS_SCALINGMETHOD_CUBIC);
++ GetInteger(pElement, "scalingmethod", scalingMethod, VS_SCALINGMETHOD_LINEAR, VS_SCALINGMETHOD_NEAREST, VS_SCALINGMETHOD_AUTO);
+ m_stSettings.m_defaultVideoSettings.m_ScalingMethod = (ESCALINGMETHOD)scalingMethod;
+
+ GetInteger(pElement, "viewmode", m_stSettings.m_defaultVideoSettings.m_ViewMode, VIEW_MODE_NORMAL, VIEW_MODE_NORMAL, VIEW_MODE_CUSTOM);
diff --git a/media-tv/xbmc/files/xbmc-9.11-use-cdio-system-headers-on-non-win32.patch b/media-tv/xbmc/files/xbmc-9.11-use-cdio-system-headers-on-non-win32.patch
new file mode 100644
index 00000000..345d9115
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9.11-use-cdio-system-headers-on-non-win32.patch
@@ -0,0 +1,129 @@
+diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
+index 9097519..9b6418d 100644
+--- a/xbmc/Application.cpp
++++ b/xbmc/Application.cpp
+@@ -236,7 +236,11 @@
+ #endif
+
+ #ifdef HAS_DVD_DRIVE
++#ifdef _WIN32
+ #include "lib/libcdio/logging.h"
++#else
++#include <cdio/logging.h>
++#endif
+ #endif
+
+ #ifdef HAS_HAL
+diff --git a/xbmc/FileSystem/Makefile b/xbmc/FileSystem/Makefile
+index 782d57a..1e524ed 100644
+--- a/xbmc/FileSystem/Makefile
++++ b/xbmc/FileSystem/Makefile
+@@ -1,5 +1,4 @@
+ INCLUDES=-I. -I../ -I../cores -I../linux -I../../guilib -I../lib/UnrarXLib -I../utils -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
+-INCLUDES+=-I../lib/libcdio/libcdio/include
+
+ CXXFLAGS+=-D__STDC_FORMAT_MACROS \
+
+diff --git a/xbmc/FileSystem/cdioSupport.cpp b/xbmc/FileSystem/cdioSupport.cpp
+index 00e5fdd..21a0b67 100644
+--- a/xbmc/FileSystem/cdioSupport.cpp
++++ b/xbmc/FileSystem/cdioSupport.cpp
+@@ -26,7 +26,7 @@
+ #include "cdioSupport.h"
+ #include "utils/SingleLock.h"
+ #include "utils/log.h"
+-#ifndef _LINUX
++#ifdef _WIN32
+ #include "lib/libcdio/logging.h"
+ #include "lib/libcdio/util.h"
+ #include "lib/libcdio/mmc.h"
+diff --git a/xbmc/FileSystem/iso9660.cpp b/xbmc/FileSystem/iso9660.cpp
+index 6e1633f..58fbc50 100644
+--- a/xbmc/FileSystem/iso9660.cpp
++++ b/xbmc/FileSystem/iso9660.cpp
+@@ -44,7 +44,7 @@ ISO9660
+ #include "utils/CharsetConverter.h"
+
+ #include "DetectDVDType.h" // for MODE2_DATA_SIZE etc.
+-#ifdef _LINUX
++#ifndef _WIN32
+ #include <cdio/bytesex.h>
+ #else
+ #include "lib/libcdio/bytesex.h" // for from_723 & from_733
+diff --git a/xbmc/Makefile b/xbmc/Makefile
+index abfbdcb..f55381a 100644
+--- a/xbmc/Makefile
++++ b/xbmc/Makefile
+@@ -8,8 +8,6 @@ INCLUDES+=-Ilib/libUPnP/Platinum/Source/Core \
+ -Ilib/libUPnP/Neptune/Source/System/Posix \
+ -Ilib/libUPnP/Neptune/Source/Core
+
+-INCLUDES+=-Ilib/libcdio/libcdio/include
+-
+ SRCS=Application.cpp \
+ CueDocument.cpp \
+ GUISettings.cpp \
+diff --git a/xbmc/cdrip/CDDAReader.cpp b/xbmc/cdrip/CDDAReader.cpp
+index c8b37b2..e3e9c0b 100644
+--- a/xbmc/cdrip/CDDAReader.cpp
++++ b/xbmc/cdrip/CDDAReader.cpp
+@@ -24,7 +24,11 @@
+ #ifdef HAS_CDDA_RIPPER
+
+ #include "CDDAReader.h"
++#ifdef _WIN32
+ #include "lib/libcdio/cdio.h"
++#else
++#include <cdio/cdio.h>
++#endif
+ #include "utils/log.h"
+
+ #define SECTOR_COUNT 52
+diff --git a/xbmc/cores/paplayer/AC3CDDACodec.cpp b/xbmc/cores/paplayer/AC3CDDACodec.cpp
+index 20cded7..f2a077a 100644
+--- a/xbmc/cores/paplayer/AC3CDDACodec.cpp
++++ b/xbmc/cores/paplayer/AC3CDDACodec.cpp
+@@ -22,7 +22,11 @@
+ #include "system.h"
+ #include "AC3CDDACodec.h"
+ #ifdef HAS_AC3_CDDA_CODEC
++#ifdef _WIN32
+ #include "lib/libcdio/sector.h"
++#else
++#include <cdio/sector.h>
++#endif
+
+ AC3CDDACodec::AC3CDDACodec() : AC3Codec()
+ {
+diff --git a/xbmc/cores/paplayer/CDDAcodec.cpp b/xbmc/cores/paplayer/CDDAcodec.cpp
+index ca8f1be..42460dc 100644
+--- a/xbmc/cores/paplayer/CDDAcodec.cpp
++++ b/xbmc/cores/paplayer/CDDAcodec.cpp
+@@ -20,7 +20,11 @@
+ */
+
+ #include "CDDAcodec.h"
++#ifdef _WIN32
+ #include "lib/libcdio/sector.h"
++#else
++#include <cdio/sector.h>
++#endif
+
+ #define SECTOR_COUNT 55 // max. sectors that can be read at once
+ #define MAX_BUFFER_SIZE 2*SECTOR_COUNT*CDIO_CD_FRAMESIZE_RAW
+diff --git a/xbmc/cores/paplayer/DTSCDDACodec.cpp b/xbmc/cores/paplayer/DTSCDDACodec.cpp
+index e64cc2e..9bc46c6 100644
+--- a/xbmc/cores/paplayer/DTSCDDACodec.cpp
++++ b/xbmc/cores/paplayer/DTSCDDACodec.cpp
+@@ -22,7 +22,11 @@
+ #include "system.h"
+ #include "DTSCDDACodec.h"
+ #ifdef HAS_DTS_CODEC
++#ifdef _WIN32
+ #include "lib/libcdio/sector.h"
++#else
++#include <cdio/sector.h>
++#endif
+
+ DTSCDDACodec::DTSCDDACodec() : DTSCodec()
+ {
diff --git a/media-tv/xbmc/files/xbmc-9.11-wavpack.patch b/media-tv/xbmc/files/xbmc-9.11-wavpack.patch
new file mode 100644
index 00000000..4ef0d147
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9.11-wavpack.patch
@@ -0,0 +1,44 @@
+fix from upstream trunk
+
+http://xbmc.org/trac/ticket/8185
+
+Index: trunk/xbmc/cores/paplayer/DllWAVPack.h
+===================================================================
+--- trunk/xbmc/cores/paplayer/DllWAVPack.h (revision 22927)
++++ trunk/xbmc/cores/paplayer/DllWAVPack.h (revision 25321)
+@@ -58,7 +58,7 @@
+ virtual int WavpackGetReducedChannels (WavpackContext *wpc)=0;
+ virtual int WavpackGetFloatNormExp (WavpackContext *wpc)=0;
+- virtual int WavpackGetMD5Sum (WavpackContext *wpc, uchar data [16])=0;
++ virtual int WavpackGetMD5Sum (WavpackContext *wpc, unsigned char data [16])=0;
+ virtual uint32_t WavpackGetWrapperBytes (WavpackContext *wpc)=0;
+- virtual uchar *WavpackGetWrapperData (WavpackContext *wpc)=0;
++ virtual unsigned char *WavpackGetWrapperData (WavpackContext *wpc)=0;
+ virtual void WavpackFreeWrapper (WavpackContext *wpc)=0;
+ virtual void WavpackSeekTrailingWrapper (WavpackContext *wpc)=0;
+@@ -77,5 +77,5 @@
+ virtual int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_t total_samples)=0;
+ virtual int WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount)=0;
+- virtual int WavpackStoreMD5Sum (WavpackContext *wpc, uchar data [16])=0;
++ virtual int WavpackStoreMD5Sum (WavpackContext *wpc, unsigned char data [16])=0;
+ virtual int WavpackPackInit (WavpackContext *wpc)=0;
+ virtual int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count)=0;
+@@ -133,9 +133,9 @@
+ virtual int WavpackGetFloatNormExp (WavpackContext *wpc)
+ { return ::WavpackGetFloatNormExp (wpc); }
+- virtual int WavpackGetMD5Sum (WavpackContext *wpc, uchar data [16])
++ virtual int WavpackGetMD5Sum (WavpackContext *wpc, unsigned char data [16])
+ { return ::WavpackGetMD5Sum (wpc, data); }
+ virtual uint32_t WavpackGetWrapperBytes (WavpackContext *wpc)
+ { return ::WavpackGetWrapperBytes (wpc); }
+- virtual uchar *WavpackGetWrapperData (WavpackContext *wpc)
++ virtual unsigned char *WavpackGetWrapperData (WavpackContext *wpc)
+ { return ::WavpackGetWrapperData (wpc); }
+ virtual void WavpackFreeWrapper (WavpackContext *wpc)
+@@ -171,5 +171,5 @@
+ virtual int WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount)
+ { return ::WavpackAddWrapper (wpc, data, bcount); }
+- virtual int WavpackStoreMD5Sum (WavpackContext *wpc, uchar data [16])
++ virtual int WavpackStoreMD5Sum (WavpackContext *wpc, unsigned char data [16])
+ { return ::WavpackStoreMD5Sum (wpc, data); }
+ virtual int WavpackPackInit (WavpackContext *wpc)
diff --git a/media-tv/xbmc/files/xbmc-9999-arm-kill-softfp.patch b/media-tv/xbmc/files/xbmc-9999-arm-kill-softfp.patch
new file mode 100644
index 00000000..c50d83e2
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9999-arm-kill-softfp.patch
@@ -0,0 +1,15 @@
+--- xbmc-9999.orig/configure.in
++++ xbmc-9999/configure.in
+@@ -572,9 +572,9 @@ if test "$host_vendor" = "apple" ; then
+ LIBS="$LIBS -framework ApplicationServices"
+ fi
+ elif test "$use_arch" = "arm"; then
+- CFLAGS="$CFLAGS -mfloat-abi=softfp -mno-apcs-stack-check"
+- CXXFLAGS="$CXXFLAGS -mfloat-abi=softfp -mno-apcs-stack-check"
+- FFMPEG_EXTRACFLAGS="-mfloat-abi=softfp"
++ CFLAGS="$CFLAGS -mno-apcs-stack-check"
++ CXXFLAGS="$CXXFLAGS -mno-apcs-stack-check"
++ FFMPEG_EXTRACFLAGS=""
+ if test "$use_tegra" = "yes"; then
+ # Compile for ARMv7a architecture, need to test gcc for vfpv3-d16 support
+ SAVE_CFLAGS="$CFLAGS"
diff --git a/media-tv/xbmc/files/xbmc-9999-libpng-1.5-fix-plt-trn-get.patch b/media-tv/xbmc/files/xbmc-9999-libpng-1.5-fix-plt-trn-get.patch
new file mode 100644
index 00000000..02954e8e
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9999-libpng-1.5-fix-plt-trn-get.patch
@@ -0,0 +1,47 @@
+--- xbmc-10.1.orig/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp
++++ xbmc-10.1/xbmc/lib/cximage-6.0/CxImage/ximapng.cpp
+@@ -178,12 +178,14 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ int _num_palette;
+ png_colorp _palette;
+ #if PNG_LIBPNG_VER > 10399
+- png_get_PLTE(png_ptr,info_ptr,&_palette,&_num_palette);
++ png_uint_32 _palette_ret;
++ _palette_ret = png_get_PLTE(png_ptr,info_ptr,&_palette,&_num_palette);
++ if (_palette_ret && _num_palette>0){
+ #else
+ _num_palette=info_ptr->num_palette;
+ _palette=info_ptr->palette;
+-#endif
+ if (_num_palette>0){
++#endif
+ SetPalette((rgb_color*)_palette,_num_palette);
+ SetClrImportant(_num_palette);
+ } else if (_bit_depth ==2) { //<DP> needed for 2 bpp grayscale PNGs
+@@ -199,11 +201,13 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ int _num_trans;
+ png_color_16p _trans_color;
+ #if PNG_LIBPNG_VER > 10399
+- png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color);
++ png_uint_32 _trans_ret;
++ _trans_ret = png_get_tRNS(png_ptr,info_ptr,&_trans_alpha,&_num_trans,&_trans_color);
++ if (_trans_ret && _num_trans!=0){ //palette transparency
+ #else
+ _num_trans=info_ptr->num_trans;
+-#endif
+ if (_num_trans!=0){ //palette transparency
++#endif
+ if (_num_trans==1){
+ if (_color_type == PNG_COLOR_TYPE_PALETTE){
+ #if PNG_LIBPNG_VER > 10399
+@@ -219,7 +223,11 @@ bool CxImagePNG::Decode(CxFile *hFile)
+ #endif
+ }
+ }
++#if PNG_LIBPNG_VER > 10399
++ if (_num_trans>1 && _trans_alpha!=NULL){
++#else
+ if (_num_trans>1){
++#endif
+ RGBQUAD* pal=GetPalette();
+ if (pal){
+ DWORD ip;
diff --git a/media-tv/xbmc/files/xbmc-9999-no-arm-flags.patch b/media-tv/xbmc/files/xbmc-9999-no-arm-flags.patch
new file mode 100644
index 00000000..179697a8
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9999-no-arm-flags.patch
@@ -0,0 +1,16 @@
+http://bugs.gentoo.org/400617
+
+do not force any particular ABI or FPU or SIMD compiler flags for arm
+targets. let the toolchain and user CFLAGS control that.
+
+--- a/configure.in
++++ b/configure.in
+@@ -571,7 +571,7 @@
+ LIBS="$LIBS -framework DiskArbitration"
+ LIBS="$LIBS -framework ApplicationServices"
+ fi
+-elif test "$use_arch" = "arm"; then
++elif false; then
+ CFLAGS="$CFLAGS -mfloat-abi=softfp -mno-apcs-stack-check"
+ CXXFLAGS="$CXXFLAGS -mfloat-abi=softfp -mno-apcs-stack-check"
+ FFMPEG_EXTRACFLAGS="-mfloat-abi=softfp"
diff --git a/media-tv/xbmc/files/xbmc-9999-no-exec-stack.patch b/media-tv/xbmc/files/xbmc-9999-no-exec-stack.patch
new file mode 100644
index 00000000..67b20b7b
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9999-no-exec-stack.patch
@@ -0,0 +1,28 @@
+http://trac.xbmc.org/ticket/12735
+
+From f0e33eefa4b5d46f26811db2f5e943dcd7f2870e Mon Sep 17 00:00:00 2001
+From: Mike Frysinger <vapier@gentoo.org>
+Date: Thu, 1 Mar 2012 00:04:49 -0500
+Subject: [PATCH] mark stack as non-executable
+
+Signed-off-by: Mike Frysinger <vapier@gentoo.org>
+---
+ xbmc/utils/fastmemcpy-arm.S | 5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+diff --git a/xbmc/utils/fastmemcpy-arm.S b/xbmc/utils/fastmemcpy-arm.S
+index 0e810a7..3d77c68 100644
+--- a/xbmc/utils/fastmemcpy-arm.S
++++ b/xbmc/utils/fastmemcpy-arm.S
+@@ -527,3 +527,8 @@ copy_last_3_and_return:
+
+ #endif /* __ARM_ARCH__ < 7 */
+ #endif
++
++#if defined(__linux__) && defined(__ELF__)
++/* we don't need an executable stack */
++.section .note.GNU-stack,"",%progbits
++#endif
+--
+1.7.8.4
+
diff --git a/media-tv/xbmc/files/xbmc-9999-nomythtv.patch b/media-tv/xbmc/files/xbmc-9999-nomythtv.patch
new file mode 100644
index 00000000..09286dba
--- /dev/null
+++ b/media-tv/xbmc/files/xbmc-9999-nomythtv.patch
@@ -0,0 +1,206 @@
+http://trac.xbmc.org/ticket/11775
+
+make mysql/mythtv support optional
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -127,13 +127,17 @@ endif
+ LIB_DIRS=\
+ lib/cximage-6.0 \
+ lib/libexif \
+- lib/cmyth \
+ lib/libhdhomerun \
+ lib/libid3tag \
+ lib/libapetag \
+ lib/cpluff \
+ lib/xbmc-dll-symbols
+
++ifeq (@BUILD_MYTHTV@,1)
++LIB_DIRS+=\
++ lib/cmyth
++endif
++
+ SS_DIRS=
+ ifeq (@USE_OPENGL@,1)
+ SS_DIRS+= xbmc/screensavers/rsxs-0.9/xbmc
+@@ -418,7 +422,10 @@ imagelib: dllloader
+ $(MAKE) -C lib/cximage-6.0
+
+ codecs: papcodecs dvdpcodecs
+-libs: cmyth libhdhomerun libid3tag imagelib libexif system/libcpluff-@ARCH@.so
++libs: libhdhomerun libid3tag imagelib libexif system/libcpluff-@ARCH@.so
++ifeq (@BUILD_MYTHTV@,1)
++libs: cmyth
++endif
+ externals: codecs libs visualizations screensavers
+
+ xcode_depends: \
+--- a/configure.in
++++ b/configure.in
+@@ -68,6 +68,9 @@ goom_enabled="== GOOM enabled. =="
+ goom_disabled="== GOOM disabled. =="
+ pulse_not_found="== Could not find libpulse. PulseAudio support disabled. =="
+ pulse_disabled="== PulseAudio support manually disabled. =="
++mysql_not_found="Could not find libmysqlclient. MySQL (and MythTV) support disabled. =="
++mysql_disabled="== MySQL support disabled. =="
++mythtv_disabled="== MythTV support disabled. =="
+ dvdcss_enabled="== DVDCSS support enabled. =="
+ dvdcss_disabled="== DVDCSS support disabled. =="
+ hal_not_found="== Could not find hal. HAL support disabled. =="
+@@ -238,6 +241,18 @@ AC_ARG_ENABLE([ffmpeg_libvorbis],
+ [use_ffmpeg_libvorbis=$enableval],
+ [use_ffmpeg_libvorbis=no])
+
++AC_ARG_ENABLE([mysql],
++ [AS_HELP_STRING([--enable-mysql],
++ [enable MySQL support (default is auto)])],
++ [use_mysql=$enableval],
++ [use_mysql=auto])
++
++AC_ARG_ENABLE([mythtv],
++ [AS_HELP_STRING([--enable-mythtv],
++ [enable MythTV support (default is auto)])],
++ [use_mythtv=$enableval],
++ [use_mythtv=auto])
++
+ AC_ARG_ENABLE([dvdcss],
+ [AS_HELP_STRING([--enable-dvdcss],
+ [enable DVDCSS support (default is yes)])],
+@@ -563,14 +578,31 @@ else
+ fi
+
+ # platform common libraries
+-AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, "yes", "no")
+-if test $MYSQL_CONFIG = "yes"; then
+- INCLUDES="$INCLUDES `mysql_config --include`"
+- MYSQL_LIBS=`mysql_config --libs`
+- LIBS="$LIBS $MYSQL_LIBS"
+- AC_SUBST(MYSQL_LIBS)
+-else
+- AC_MSG_ERROR($missing_program)
++have_mysql=no
++if test "$use_mysql" != "no"; then
++ AC_CHECK_PROG(MYSQL_CONFIG, mysql_config, "yes", "no")
++ if test $MYSQL_CONFIG = "yes"; then
++ INCLUDES="$INCLUDES `mysql_config --include`"
++ MYSQL_LIBS=`mysql_config --libs`
++ LIBS="$LIBS $MYSQL_LIBS"
++ AC_SUBST(MYSQL_LIBS)
++ AC_CHECK_LIB([mysqlclient], [main], have_mysql=yes)
++ fi
++fi
++if test "$have_mysql" = "yes"; then
++ BUILD_MYTHTV=1
++ AC_DEFINE([BUILD_MYSQL], [1], [Define to 1 to build MySQL.])
++ if test "$use_mysql" != "no"; then
++ AC_DEFINE([BUILD_MYTHTV], [1], [Define to 1 to build mythtv.])
++ fi
++elif test "$use_mysql" = "yes" || test "$use_mythtv" = "yes"; then
++ AC_MSG_ERROR([$mysql_not_found])
++else
++ BUILD_MYTHTV=0
++ use_mysql=no
++ AC_MSG_NOTICE($mysql_disabled)
++ use_mythtv=no
++ AC_MSG_NOTICE($mythtv_disabled)
+ fi
+ AC_CHECK_HEADER([ass/ass.h],, AC_MSG_ERROR($missing_library))
+ AC_CHECK_HEADER([mpeg2dec/mpeg2.h],, AC_MSG_ERROR($missing_library))
+@@ -594,7 +625,6 @@ AC_CHECK_LIB([lzo2], [main],, AC_MSG_ERROR($missing_library))
+ AC_CHECK_LIB([z], [main],, AC_MSG_ERROR($missing_library))
+ AC_CHECK_LIB([crypto], [main],, AC_MSG_ERROR($missing_library))
+ AC_CHECK_LIB([ssl], [main],, AC_MSG_ERROR($missing_library))
+-AC_CHECK_LIB([mysqlclient], [main],, AC_MSG_ERROR($missing_library))
+ AC_CHECK_LIB([ssh], [sftp_tell64],, AC_MSG_RESULT([Could not find suitable version of libssh]))
+ AC_CHECK_LIB([smbclient], [main],, AC_MSG_ERROR($missing_library))
+ AC_CHECK_LIB([bluetooth], [hci_devid],, AC_MSG_RESULT([Could not find suitable version of libbluetooth]))
+@@ -1319,6 +1349,18 @@ else
+ final_message="$final_message\n HAL Support:\tNo"
+ fi
+
++if test "$use_mysql" = "yes"; then
++ final_message="$final_message\n MySQL:\tYes"
++else
++ final_message="$final_message\n MySQL:\tNo"
++fi
++
++if test "$use_mythtv" = "yes"; then
++ final_message="$final_message\n MythTV:\tYes"
++else
++ final_message="$final_message\n MythTV:\tNo"
++fi
++
+ # DVDCSS
+ if test "$use_dvdcss" = "yes"; then
+ AC_MSG_NOTICE($dvdcss_enabled)
+@@ -1490,6 +1532,8 @@ AC_SUBST(USE_EXTERNAL_FFMPEG)
+ AC_SUBST(PYTHON_VERSION)
+ AC_SUBST(OUTPUT_FILES)
+ AC_SUBST(HAVE_XBMC_NONFREE)
++AC_SUBST(BUILD_MYSQL)
++AC_SUBST(BUILD_MYTHTV)
+ AC_SUBST(USE_ASAP_CODEC)
+ AC_SUBST(LIBCURL_BASENAME)
+ AC_SUBST(LIBFLAC_BASENAME)
+--- a/xbmc/dbwrappers/Database.cpp
++++ b/xbmc/dbwrappers/Database.cpp
+@@ -29,7 +29,9 @@
+ #include "utils/AutoPtrHandle.h"
+ #include "utils/log.h"
+ #include "utils/URIUtils.h"
++#ifdef BUILD_MYSQL
+ #include "mysqldataset.h"
++#endif /* BUILD_MYSQL */
+ #include "sqlitedataset.h"
+
+
+@@ -266,6 +268,7 @@
+
+ m_sqlite = true;
+
++#ifdef BUILD_MYSQL
+ if ( dbSettings.type.Equals("mysql") )
+ {
+ // check we have all information before we cancel the fallback
+@@ -276,7 +279,8 @@
+ CLog::Log(LOGINFO, "Essential mysql database information is missing. Require at least host, user and pass defined.");
+ }
+ else
++#endif /* BUILD_MYSQL */
+ {
+ dbSettings.type = "sqlite3";
+ dbSettings.host = _P(g_settings.GetDatabaseFolder());
+ dbSettings.name = GetBaseDBName();
+@@ -369,10 +373,12 @@
+ {
+ m_pDB.reset( new SqliteDatabase() ) ;
+ }
++#ifdef BUILD_MYSQL
+ else if (dbSettings.type.Equals("mysql"))
+ {
+ m_pDB.reset( new MysqlDatabase() ) ;
+ }
++#endif /* BUILD_MYSQL */
+ else
+ {
+ CLog::Log(LOGERROR, "Unable to determine database type: %s", dbSettings.type.c_str());
+--- a/xbmc/dbwrappers/mysqldataset.cpp
++++ b/xbmc/dbwrappers/mysqldataset.cpp
+@@ -23,9 +23,11 @@
+ #include <string>
+ #include <set>
+
++#include "system.h" // for GetLastError()
++#ifdef BUILD_MYSQL
++
+ #include "mysqldataset.h"
+ #include "utils/log.h"
+-#include "system.h" // for GetLastError()
+ #include "mysql/errmsg.h"
+ #ifdef _WIN32
+ #pragma comment(lib, "mysqlclient.lib")
+@@ -1562,3 +1564,4 @@
+
+ }//namespace
+
++#endif /* BUILD_MYSQL */