Skip to content

Commit

Permalink
Merge pull request xbmc#22546 from quietvoid/libdovi
Browse files Browse the repository at this point in the history
[depends][Android] Add base dependencies setup for libdovi
  • Loading branch information
fuzzard authored Sep 3, 2023
2 parents d14ae35 + cfcb8a2 commit d3f1d4b
Show file tree
Hide file tree
Showing 17 changed files with 312 additions and 2 deletions.
12 changes: 12 additions & 0 deletions addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -23481,3 +23481,15 @@ msgstr ""
msgctxt "#39195"
msgid "Enable this option for the best picture quality. Disabling reduces the load on resource-limited systems."
msgstr ""

#. Title of Dolby Vision RPU conversion setting
#: system/settings/settings.xml
msgctxt "#39196"
msgid "Dolby Vision compatibility mode"
msgstr ""

#. Help text for setting "Convert Dolby Vision for compatibility" of label #39196
#: system/settings/settings.xml
msgctxt "#39197"
msgid "If enabled, Dolby Vision profile 7 will be converted to profile 8.1, which is more commonly supported by devices. Enable if your device supports Dolby Vision, but has issues with some videos."
msgstr ""
32 changes: 32 additions & 0 deletions cmake/modules/FindLibDovi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# FindDovi
# -------
# Finds the libdovi library
#
# This will define the following variables::
#
# LIBDOVI_FOUND - system has libdovi
# LIBDOVI_INCLUDE_DIRS - the libdovi include directories
# LIBDOVI_LIBRARIES - the libdovi libraries
# LIBDOVI_DEFINITIONS - the libdovi compile definitions

if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBDOVI libdovi QUIET)
endif()

find_library(LIBDOVI_LIBRARY NAMES dovi libdovi
PATHS ${PC_LIBDOVI_LIBDIR}
)
find_path(LIBDOVI_INCLUDE_DIR NAMES libdovi/rpu_parser.h
PATHS ${PC_LIBDOVI_INCLUDEDIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibDovi
REQUIRED_VARS LIBDOVI_LIBRARY LIBDOVI_INCLUDE_DIR)

if(LIBDOVI_FOUND)
set(LIBDOVI_INCLUDE_DIRS ${LIBDOVI_INCLUDE_DIR})
set(LIBDOVI_LIBRARIES ${LIBDOVI_LIBRARY})
set(LIBDOVI_DEFINITIONS -DHAVE_LIBDOVI=1)
endif()

mark_as_advanced(LIBDOVI_INCLUDE_DIR LIBDOVI_LIBRARY)
1 change: 1 addition & 0 deletions cmake/platform/android/android.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(PLATFORM_REQUIRED_DEPS LibAndroidJNI OpenGLES EGL LibZip)
set(APP_RENDER_SYSTEM gles)
list(APPEND PLATFORM_OPTIONAL_DEPS LibDovi)

# Store SDK compile version
set(TARGET_SDK 33)
Expand Down
11 changes: 11 additions & 0 deletions system/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@
<default>true</default>
<control type="toggle" />
</setting>
<setting id="videoplayer.convertdovi" type="boolean" label="39196" help="39197">
<requirement>HAS_MEDIACODEC</requirement>
<dependencies>
<dependency type="visible">
<condition on="property" name="supportsdolbyvision" />
</dependency>
</dependencies>
<level>2</level>
<default>false</default>
<control type="toggle" />
</setting>
</group>
<group id="4" label="14232">
<setting id="videoplayer.stereoscopicplaybackmode" type="integer" label="36520" help="36537">
Expand Down
5 changes: 5 additions & 0 deletions tools/depends/native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ ifeq ($(OS),linux)
endif
endif

ifeq ($(OS),android)
NATIVE += rustup cargo-c
endif

.PHONY: $(NATIVE) native download $(DOWNLOAD_TARGETS)

all: native
Expand All @@ -65,6 +69,7 @@ download: $(DOWNLOAD_TARGETS)
autoconf-archive: autoconf
autoconf: m4
automake: autoconf
cargo-c: pkg-config openssl rustup
dpkg: automake gettext libtool pkg-config tar
heimdal: libtool
JsonSchemaBuilder: cmake
Expand Down
5 changes: 5 additions & 0 deletions tools/depends/native/cargo-c/CARGO-C-VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APPNAME=cargo-c
VERSION=0.9.21
SOURCE=$(APPNAME)-$(VERSION)
ARCHIVE=$(SOURCE).tar.gz
SHA512=855391c29843f8e5f204f889cab16d5d569ebb2174367a8be0d4be3d87141133f98fb7a6750ed0030783a1ff29f358d60c6ca79ed5bb65f61196c726f9c1a0ec
38 changes: 38 additions & 0 deletions tools/depends/native/cargo-c/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
include ../../Makefile.include CARGO-C-VERSION ../../download-files.include
DEPS = ../../Makefile.include Makefile CARGO-C-VERSION ../../download-files.include

PREFIX=$(NATIVEPREFIX)
PLATFORM=$(NATIVEPLATFORM)

export PKG_CONFIG_PATH=$(PREFIX)/lib/pkgconfig

APP=$(PLATFORM)/target/release/$(APPNAME)

CARGO_ENV_VARS = RUSTUP_HOME=$(PREFIX)/.rustup \
CARGO_HOME=$(PREFIX)/.cargo
CARGO = $(CARGO_ENV_VARS) $(PREFIX)/bin/cargo

CLEANUP_CMD = [ -e $(PREFIX)/bin/cargo ] \
&& $(CARGO) uninstall cargo-c || true

all: .installed-$(PLATFORM)

$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE)
rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM)
cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)

$(APP): $(PLATFORM)
$(CARGO) build --release --manifest-path $(PLATFORM)/Cargo.toml

.installed-$(PLATFORM): $(APP)
$(CARGO) install --profile release --path $(PLATFORM)

touch $@

clean:
$(CLEANUP_CMD)
rm -f .installed-$(PLATFORM)

distclean::
$(CLEANUP_CMD)
rm -rf $(PLATFORM) .installed-$(PLATFORM)
51 changes: 51 additions & 0 deletions tools/depends/native/rustup/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
include ../../Makefile.include RUSTUP-VERSION ../../download-files.include
DEPS = ../../Makefile.include Makefile RUSTUP-VERSION ../../download-files.include

PREFIX=$(NATIVEPREFIX)
PLATFORM=$(NATIVEPLATFORM)

APP=$(PLATFORM)/bin/$(APPNAME)

export RUSTUP_HOME=$(PREFIX)/.rustup
export CARGO_HOME=$(PREFIX)/.cargo

RUST_TOOLCHAIN_VERSION=1.71.0
RUSTUP_ENV_VARS = RUSTUP_HOME=$(PREFIX)/.rustup \
CARGO_HOME=$(PREFIX)/.cargo
RUSTUP = $(RUSTUP_ENV_VARS) $(PREFIX)/bin/rustup

CLEANUP_CMD=[ -e $(PREFIX)/bin/rustup ] \
&& $(RUSTUP) self uninstall -y \
&& rm -f $(PREFIX)/bin/rustup \
&& rm -f $(PREFIX)/bin/cargo || true

all: .installed-$(PLATFORM)

$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE)
rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM)
cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)

$(APP): $(PLATFORM)
bash $(PLATFORM)/rustup-init.sh -y --no-modify-path \
--profile minimal \
--default-toolchain=$(RUST_TOOLCHAIN_VERSION)

.installed-$(PLATFORM): $(APP)
ln -sf $(CARGO_HOME)/bin/rustup $(PREFIX)/bin/rustup
ln -sf $(CARGO_HOME)/bin/cargo $(PREFIX)/bin/cargo

$(RUSTUP) default $(RUST_TOOLCHAIN_VERSION)

ifeq ($(CROSS_COMPILING),yes)
$(RUSTUP) target add $(HOST)
endif

touch $@

clean:
$(CLEANUP_CMD)
rm -f .installed-$(PLATFORM)

distclean::
$(CLEANUP_CMD)
rm -rf $(PLATFORM) .installed-$(PLATFORM)
5 changes: 5 additions & 0 deletions tools/depends/native/rustup/RUSTUP-VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APPNAME=rustup
VERSION=1.26.0
SOURCE=$(APPNAME)-$(VERSION)
ARCHIVE=$(SOURCE).tar.gz
SHA512=bc7cb580640248a601dbafb87c3a9e908b6c687377b4e0f88280576af15527f5837d9463f7831c14b0c274cd3170449e634cd851e0d03ea4ff1d0461d4a941be
2 changes: 1 addition & 1 deletion tools/depends/target/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endif

ifeq ($(OS),android)
EXCLUDED_DEPENDS = libcec libusb gtest
DEPENDS += dummy-libxbmc libuuid
DEPENDS += dummy-libxbmc libdovi libuuid
PYMODULE_DEPS = dummy-libxbmc
LIBUUID = libuuid
endif
Expand Down
6 changes: 6 additions & 0 deletions tools/depends/target/libdovi/LIBDOVI-VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LIBNAME=libdovi
VERSION=3.1.2
SOURCE=$(LIBNAME)-$(VERSION)
ARCHIVE=$(SOURCE).tar.gz
SHA512=577d5a5916dedbf222150ddb76219325e0e9a7ae91c5978b1b1fd65048d1f548e29aa8ebbbdc836380ec399e2bc105a722515f783be70837dc6403cb34586bb2
BYPRODUCT=libdovi.a
43 changes: 43 additions & 0 deletions tools/depends/target/libdovi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
include ../../Makefile.include LIBDOVI-VERSION ../../download-files.include
DEPS = ../../Makefile.include Makefile LIBDOVI-VERSION ../../download-files.include

LIBDYLIB=$(PLATFORM)/target/$(HOST)/release/$(BYPRODUCT)

CARGO_ENV_VARS = RUSTUP_HOME=$(NATIVEPREFIX)/.rustup \
CARGO_HOME=$(NATIVEPREFIX)/.cargo
CARGO = $(CARGO_ENV_VARS) $(NATIVEPREFIX)/bin/cargo

CARGO_BASE_OPTS = --manifest-path $(PLATFORM)/dolby_vision/Cargo.toml
ifeq ($(CROSS_COMPILING),yes)
CARGO_BASE_OPTS += --target $(HOST)
endif

CARGO_BUILD_OPTS = --offline \
--frozen \
--library-type staticlib \
--profile release \
--prefix $(PREFIX) \
$(CARGO_BASE_OPTS)

all: .installed-$(PLATFORM)

$(PLATFORM): $(DEPS) | $(TARBALLS_LOCATION)/$(ARCHIVE).$(HASH_TYPE)
rm -rf $(PLATFORM)/*; mkdir -p $(PLATFORM)
cd $(PLATFORM); $(ARCHIVE_TOOL) $(ARCHIVE_TOOL_FLAGS) $(TARBALLS_LOCATION)/$(ARCHIVE)
cd $(PLATFORM);
$(CARGO) fetch $(CARGO_BASE_OPTS)

$(LIBDYLIB): $(PLATFORM)
$(CARGO) cbuild $(CARGO_BUILD_OPTS)

.installed-$(PLATFORM): $(LIBDYLIB)
$(CARGO) cinstall $(CARGO_BUILD_OPTS)

touch $@

clean:
cd $(PLATFORM); $(CARGO) clean
rm -f .installed-$(PLATFORM)

distclean::
rm -rf $(PLATFORM) .installed-$(PLATFORM)
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,22 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio
{
m_bitstream.reset();
}

// Only set for profile 7, container hint allows to skip parsing unnecessarily
if (m_bitstream && m_hints.dovi.dv_profile == 7)
{
bool convertDovi = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
CSettings::SETTING_VIDEOPLAYER_CONVERTDOVI);

CLog::Log(LOGDEBUG,
"CDVDVideoCodecAndroidMediaCodec::Open Dolby Vision compatibility mode "
"enabled: {}",
convertDovi);

m_bitstream->SetConvertDovi(convertDovi);
}
}

break;
}
case AV_CODEC_ID_WMV3:
Expand Down
9 changes: 9 additions & 0 deletions xbmc/settings/SettingConditions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ bool SupportsVideoSuperResolution(const std::string& condition,
return CServiceBroker::GetWinSystem()->SupportsVideoSuperResolution();
}

bool SupportsDolbyVision(const std::string& condition,
const std::string& value,
const SettingConstPtr& setting,
void* data)
{
return CServiceBroker::GetWinSystem()->GetDisplayHDRCapabilities().SupportsDolbyVision();
}

bool SupportsScreenMove(const std::string& condition,
const std::string& value,
const SettingConstPtr& setting,
Expand Down Expand Up @@ -470,6 +478,7 @@ void CSettingConditions::Initialize()
m_complexConditions.emplace("hassystemsdrpeakluminance", HasSystemSdrPeakLuminance);
m_complexConditions.emplace("supportsscreenmove", SupportsScreenMove);
m_complexConditions.emplace("supportsvideosuperresolution", SupportsVideoSuperResolution);
m_complexConditions.emplace("supportsdolbyvision", SupportsDolbyVision);
m_complexConditions.emplace("ishdrdisplay", IsHDRDisplay);
m_complexConditions.emplace("ismasteruser", IsMasterUser);
m_complexConditions.emplace("hassubtitlesfontextensions", HasSubtitlesFontExtensions);
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class CSettings : public CSettingsBase, public CSettingCreator, public CSettingC
static constexpr auto SETTING_VIDEOPLAYER_USESTAGEFRIGHT = "videoplayer.usestagefright";
static constexpr auto SETTING_VIDEOPLAYER_LIMITGUIUPDATE = "videoplayer.limitguiupdate";
static constexpr auto SETTING_VIDEOPLAYER_SUPPORTMVC = "videoplayer.supportmvc";
static constexpr auto SETTING_VIDEOPLAYER_CONVERTDOVI = "videoplayer.convertdovi";
static constexpr auto SETTING_MYVIDEOS_SELECTACTION = "myvideos.selectaction";
static constexpr auto SETTING_MYVIDEOS_USETAGS = "myvideos.usetags";
static constexpr auto SETTING_MYVIDEOS_EXTRACTFLAGS = "myvideos.extractflags";
Expand Down
Loading

0 comments on commit d3f1d4b

Please sign in to comment.