Skip to content

Commit

Permalink
Merge pull request xbmc#9702 from FernetMenta/vtb
Browse files Browse the repository at this point in the history
VideoPlayer: OSX/iOS - use ffmpeg videotoolbox
  • Loading branch information
FernetMenta committed May 1, 2016
2 parents a09f146 + 8c06005 commit 0bae239
Show file tree
Hide file tree
Showing 39 changed files with 774 additions and 2,786 deletions.
99 changes: 55 additions & 44 deletions Kodi.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -6608,7 +6608,7 @@ msgstr ""

#: system/settings/settings.xml
msgctxt "#13429"
msgid "Allow hardware acceleration - VDADecoder"
msgid "Allow hardware acceleration - VTBDecoder"
msgstr ""

#: system/settings/settings.xml
Expand Down Expand Up @@ -16340,10 +16340,10 @@ msgctxt "#36159"
msgid "Enable CrystalHD decoding of video files."
msgstr ""

#. Description of setting "Videos -> Playback -> Allow hardware acceleration (VDADecoder)" with label #13429
#. Description of setting "Videos -> Playback -> Allow hardware acceleration (VideoToolbox)" with label #13429
#: system/settings/settings.xml
msgctxt "#36160"
msgid "Enable VDA hardware decoding of video files."
msgid "Enable VTB hardware decoding of video files."
msgstr ""

#. Description of setting "Videos -> Playback -> Allow hardware acceleration (OpenMax)" with label #13430
Expand Down
53 changes: 9 additions & 44 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ AC_DEFUN([XB_FIND_SONAME],
for path in $gcc_lib_path $env_lib_path $host_lib_path; do
lib=[`ls -- $path/lib$2.dylib 2>/dev/null`]
if test x$lib != x; then
# we want the path/name that is embedded in the dylib
# we want the path/name that is embedded in the dylib
$1_FILENAME=[`otool -L $lib | grep -v lib$2.dylib | grep lib$2 | awk '{V=1; print $V}'`]
$1_SONAME=[`basename $$1_FILENAME`]
fi
Expand Down Expand Up @@ -184,8 +184,6 @@ vdpau_not_found="== Could not find libvdpau. VDPAU support disabled. =="
vdpau_disabled="== VDPAU support manually disabled. =="
vaapi_not_found="== Could not find libva. VAAPI support disabled. =="
vaapi_disabled="== VAAPI support manually disabled. =="
vtbdecoder_enabled="== VTBDecoder support enabled. =="
vtbdecoder_disabled="== VTBDecoder support manually disabled. =="
openmax_disabled="== OpenMax support manually disabled. =="
openmax_not_found="== Could not find OpenMax headers. OpenMax support disabled. =="
librtmp_not_found="== Could not find libRTMP. RTMP support disabled. =="
Expand Down Expand Up @@ -271,12 +269,6 @@ AC_ARG_ENABLE([vaapi],
[use_vaapi=$enableval],
[use_vaapi=auto])

AC_ARG_ENABLE([vtbdecoder],
[AS_HELP_STRING([--enable-vtbdecoder],
[enable VTBDecoder decoding (default is auto)])],
[use_vtbdecoder=$enableval],
[use_vtbdecoder=auto])

AC_ARG_ENABLE([openmax],
[AS_HELP_STRING([--enable-openmax],
[enable OpenMax decoding (default is auto, requires OpenGLES)])],
Expand Down Expand Up @@ -378,7 +370,7 @@ AC_ARG_ENABLE([avahi],
[disable Avahi support (default is enabled if libavahi-common and libavahi-client is found)])],
[use_avahi=$enableval],
[use_avahi=yes])

AC_ARG_ENABLE([mdnsembedded],
[AS_HELP_STRING([--disable-mdnsembedded],
[disable mDNSEmbedded support (default is auto)])],
Expand Down Expand Up @@ -533,7 +525,7 @@ case $host in
use_gles=yes
use_optical_drive=no
use_x11=no
build_shared_lib=yes
build_shared_lib=yes
;;
i*86*-linux-gnu*|i*86*-*-linux-uclibc*)
target_platform=target_linux
Expand Down Expand Up @@ -584,7 +576,6 @@ case $host in
CORE_SYSTEM_NAME=ios
use_neon=yes
use_libcec=no
use_vtbdecoder=yes
use_optical_drive=no
use_gles=yes
use_cpu=cortex-a8
Expand All @@ -600,14 +591,12 @@ case $host in
;;
*86*-apple-darwin*)
CORE_SYSTEM_NAME=osx
use_vtbdecoder=no
ARCH="x86-osx"
DEPENDS_ROOT_FOR_XCODE=$(echo ${prefix%/*})
AC_SUBST([DEPENDS_ROOT_FOR_XCODE])
;;
powerpc-apple-darwin*)
CORE_SYSTEM_NAME=osx
use_vtbdecoder=no
ARCH="powerpc-osx"
use_arch="ppc"
DEPENDS_ROOT_FOR_XCODE=$(echo ${prefix%/*})
Expand Down Expand Up @@ -793,7 +782,7 @@ elif test "$use_arch" = "arm"; then
CFLAGS="$CFLAGS -mno-apcs-stack-check"
CXXFLAGS="$CXXFLAGS -mno-apcs-stack-check"
if test "$use_tegra" = "yes"; then
# Compile for ARMv7a architecture, need to test gcc for vfpv3-d16 support
# Compile for ARMv7a architecture, need to test gcc for vfpv3-d16 support
SAVE_CFLAGS="$CFLAGS"
CFLAGS="-mfpu=vfpv3-d16"
AC_COMPILE_IFELSE(
Expand All @@ -802,10 +791,10 @@ elif test "$use_arch" = "arm"; then
CXXFLAGS="$CXXFLAGS -Wno-psabi -Wa,-march=armv7a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mthumb-interwork"
use_cpu=cortex-a9],
[ CFLAGS="$SAVE_CFLAGS -Wa,-march=armv6 -mtune=cortex-a8 -mthumb-interwork"
CXXFLAGS="$CXXFLAGS -Wa,-march=armv6 -mtune=cortex-a8 -mthumb-interwork"
CXXFLAGS="$CXXFLAGS -Wa,-march=armv6 -mtune=cortex-a8 -mthumb-interwork"
use_cpu=cortex-a8])
else
if test "$use_neon" = "yes"; then
if test "$use_neon" = "yes"; then
CFLAGS="$CFLAGS -mfpu=neon -mvectorize-with-neon-quad"
CXXFLAGS="$CXXFLAGS -mfpu=neon -mvectorize-with-neon-quad"
fi
Expand Down Expand Up @@ -1578,7 +1567,7 @@ fi

if test "$FFMPEG_FOUND" != "true"; then
PKG_CHECK_MODULES([FFMPEG], [$FFMPEG_LIBNAMES],
[INCLUDES="$INCLUDES $FFMPEG_CFLAGS"; LIBS="$LIBS $FFMPEG_LIBS"; FFMPEG_FOUND="true"],
[INCLUDES="$INCLUDES $FFMPEG_CFLAGS"; LIBS="$LIBS $FFMPEG_LIBS"; FFMPEG_FOUND="true"],
[AC_MSG_ERROR("ffmpeg not found")])
fi

Expand Down Expand Up @@ -1687,24 +1676,6 @@ else
USE_VAAPI=0
fi

# VTBDecoder
if test "x$use_vtbdecoder" != "xno"; then
if test "$host_vendor" = "apple" ; then
HAVE_VIDEOTOOLBOXDECODER=1
AC_DEFINE([HAVE_VIDEOTOOLBOXDECODER], [1], [Define to 1 if you have the 'VTBDecoder' library.])
AC_MSG_NOTICE($vtbdecoder_enabled)
else
if test "x$use_vtbdecoder" = "xyes"; then
AC_MSG_ERROR([VTB Decoder not supported on this platform])
else
use_vtbdecoder="no"
AC_MSG_NOTICE($vtbdecoder_disabled)
fi
fi
else
AC_MSG_NOTICE($vtbdecoder_disabled)
fi

# OpenMax
if test "$use_gles" = "yes" && test "$use_openmax" = "auto"; then

Expand Down Expand Up @@ -1886,12 +1857,6 @@ else
final_message="$final_message\n VAAPI:\tNo"
fi

if test "x$use_vtbdecoder" != "xno"; then
final_message="$final_message\n VTBDecoder:\tYes"
else
final_message="$final_message\n VTBDecoder:\tNo"
fi

if test "$use_openmax" != "no"; then
final_message="$final_message\n OpenMax:\tYes"
else
Expand Down Expand Up @@ -2073,7 +2038,7 @@ else
fi

if test "x$use_airtunes" != "xno"; then
final_message="$final_message\n AirTunes support (libshairplay):\tYes"
final_message="$final_message\n AirTunes support (libshairplay):\tYes"
else
final_message="$final_message\n AirTunes support:\tNo"
fi
Expand Down Expand Up @@ -2387,7 +2352,7 @@ XB_CONFIG_MODULE([lib/cpluff], [
--host=$host_alias \
--build=$build_alias \
--target=$target_alias CFLAGS="$CFLAGS" CC="$CC" CXX="$CXX" LDFLAGS="$LDFLAGS" LIBS=""
#LDFLAGS="$LDFLAGS -Wl,-read_only_relocs,suppress"
#LDFLAGS="$LDFLAGS -Wl,-read_only_relocs,suppress"
], [0])

XB_CONFIG_MODULE([lib/gtest], [
Expand Down
12 changes: 3 additions & 9 deletions system/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -811,14 +811,8 @@
<default>true</default>
<control type="toggle" />
</setting>
<setting id="videoplayer.usevideotoolbox" type="boolean" label="13432" help="36162">
<requirement>HasVideoToolBoxDecoder</requirement>
<level>2</level>
<default>true</default>
<control type="toggle" />
</setting>
<setting id="videoplayer.usevda" type="boolean" label="13429" help="36160">
<requirement>HasVDA</requirement>
<setting id="videoplayer.usevtb" type="boolean" label="13429" help="36160">
<requirement>HasVTB</requirement>
<level>2</level>
<default>true</default>
<control type="toggle" />
Expand Down Expand Up @@ -1049,7 +1043,7 @@
<level>1</level>
<default></default>
<constraints>
<allowempty>true</allowempty>
<allowempty>true</allowempty>
<addontype>xbmc.subtitle.module</addontype>
</constraints>
<control type="button" format="addon">
Expand Down
10 changes: 7 additions & 3 deletions system/shaders/output.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if (XBMC_DITHER)
#if defined(XBMC_DITHER)
uniform sampler2D m_dither;
uniform float m_ditherquant;
uniform vec2 m_dithersize;
Expand All @@ -8,11 +8,15 @@ void main()
{
vec4 rgb = process();

#if (XBMC_FULLRANGE)
#if defined(XBMC_FULLRANGE)
#if __VERSION__ <= 120
rgb = (rgb-(16.0/255.0)) * 255.0/219.0;
#else
rgb = clamp((rgb-(16.0/255.0)) * 255.0/219.0, 0, 1);
#endif
#endif

#if (XBMC_DITHER)
#if defined(XBMC_DITHER)
vec2 ditherpos = gl_FragCoord.xy / m_dithersize;
// ditherval is multiplied by 65536/(dither_size^2) to make it [0,1[
// FIXME: scale dither values before uploading?
Expand Down
2 changes: 1 addition & 1 deletion tools/darwin/Configurations/App-OSX.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ARCHS = i386 x86_64
ONLY_ACTIVE_ARCH = YES

SDKROOT = macosx
MACOSX_DEPLOYMENT_TARGET = 10.7
MACOSX_DEPLOYMENT_TARGET = 10.8

XBMC_DEPENDS = $(XBMC_DEPENDS_ROOT)/$(SDK_NAME)_$(CURRENT_ARCH)-target

Expand Down
4 changes: 2 additions & 2 deletions tools/depends/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ case $host in
4.* | 4.*.*)
platform_cc=llvm-gcc-4.2
platform_cxx=llvm-g++-4.2
;;
;;
*)
platform_cc=clang
platform_cxx=clang++
Expand Down Expand Up @@ -254,7 +254,7 @@ case $host in
AC_MSG_ERROR(error in configure of --with-sdk=$use_sdk)
esac
sdk_name=macosx$use_sdk
platform_min_version="macosx-version-min=10.7"
platform_min_version="macosx-version-min=10.8"

use_sdk_path=[`$use_xcodebuild -version -sdk $sdk_name Path`]
platform_os="osx"
Expand Down
5 changes: 2 additions & 3 deletions tools/depends/target/ffmpeg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ ifeq ($(OS), ios)
ffmpg_config += --cpu=cortex-a8
endif
ffmpg_config += --yasmexe=$(NATIVEPREFIX)/bin/yasm
ffmpg_config += --disable-decoder=mpeg_xvmc --disable-vda --disable-crystalhd --disable-videotoolbox
ffmpg_config += --disable-decoder=mpeg_xvmc --disable-vda --disable-crystalhd --enable-videotoolbox
ffmpg_config += --target-os=darwin
endif
ifeq ($(OS), osx)
ffmpg_config += --disable-outdev=sdl
ffmpg_config += --disable-decoder=mpeg_xvmc --enable-vda --disable-crystalhd --disable-videotoolbox
ffmpg_config += --disable-decoder=mpeg_xvmc --disable-vda --disable-crystalhd --enable-videotoolbox
ffmpg_config += --target-os=darwin
ffmpg_config += --disable-securetransport
endif
Expand Down Expand Up @@ -89,4 +89,3 @@ clean:

distclean::
rm -rf $(PLATFORM) .installed-$(PLATFORM)

6 changes: 0 additions & 6 deletions xbmc/cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
#include "Overlay/DVDOverlayCodec.h"
#include "cores/VideoPlayer/DVDCodecs/DVDCodecs.h"

#if defined(HAVE_VIDEOTOOLBOXDECODER)
#include "Video/DVDVideoCodecVideoToolBox.h"
#include "utils/SystemInfo.h"
#endif
#include "Video/DVDVideoCodecFFmpeg.h"
#include "Video/DVDVideoCodecOpenMax.h"
#if defined(HAS_IMXVPU)
Expand Down Expand Up @@ -150,8 +146,6 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, CProces

#if defined(HAS_IMXVPU)
pCodec = OpenCodec(new CDVDVideoCodecIMX(processInfo), hint, options);
#elif defined(HAVE_VIDEOTOOLBOXDECODER)
pCodec = OpenCodec(new CDVDVideoCodecVideoToolBox(processInfo), hint, options);
#elif defined(TARGET_ANDROID)
pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(processInfo), hint, options);
#elif defined(HAVE_LIBOPENMAX)
Expand Down
27 changes: 20 additions & 7 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
#ifdef HAVE_LIBVA
#include "VAAPI.h"
#endif
#ifdef TARGET_DARWIN_OSX
#include "VDA.h"
#ifdef TARGET_DARWIN
#include "VTB.h"
#endif
#ifdef HAS_MMAL
#include "MMALFFmpeg.h"
Expand Down Expand Up @@ -164,10 +164,10 @@ enum AVPixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avct
}
#endif

#ifdef TARGET_DARWIN_OSX
if (*cur == AV_PIX_FMT_VDA && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVDA) && g_advancedSettings.m_useFfmpegVda)
#ifdef TARGET_DARWIN
if (*cur == AV_PIX_FMT_VIDEOTOOLBOX && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVTB))
{
VDA::CDecoder* dec = new VDA::CDecoder();
VTB::CDecoder* dec = new VTB::CDecoder();
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
Expand Down Expand Up @@ -289,8 +289,8 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
if(CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEDXVA2))
tryhw = true;
#endif
#ifdef TARGET_DARWIN_OSX
if(CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVDA))
#ifdef TARGET_DARWIN
if(CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVTB))
tryhw = true;
#endif
#ifdef HAS_MMAL
Expand Down Expand Up @@ -490,6 +490,19 @@ void CDVDVideoCodecFFmpeg::SetFilters()
}
}

void CDVDVideoCodecFFmpeg::UpdateName()
{
if(m_pCodecContext->codec->name)
m_name = std::string("ff-") + m_pCodecContext->codec->name;
else
m_name = "ffmpeg";

if(m_pHardware)
m_name += "-" + m_pHardware->Name();

CLog::Log(LOGDEBUG, "CDVDVideoCodecFFmpeg - Updated codec: %s", m_name.c_str());
}

union pts_union
{
double pts_d;
Expand Down
12 changes: 1 addition & 11 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,7 @@ class CDVDVideoCodecFFmpeg : public CDVDVideoCodec
void FilterClose();
int FilterProcess(AVFrame* frame);
void SetFilters();

void UpdateName()
{
if(m_pCodecContext->codec->name)
m_name = std::string("ff-") + m_pCodecContext->codec->name;
else
m_name = "ffmpeg";

if(m_pHardware)
m_name += "-" + m_pHardware->Name();
}
void UpdateName();

AVFrame* m_pFrame;
AVFrame* m_pDecodedFrame;
Expand Down
Loading

0 comments on commit 0bae239

Please sign in to comment.