diff options
-rw-r--r-- | addons/resource.language.en_gb/resources/strings.po | 18 | ||||
-rwxr-xr-x | system/settings/settings.xml | 15 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp | 38 | ||||
-rw-r--r-- | xbmc/settings/Settings.h | 4 | ||||
-rw-r--r-- | xbmc/utils/BitstreamConverter.cpp | 6 | ||||
-rw-r--r-- | xbmc/utils/BitstreamConverter.h | 2 |
6 files changed, 72 insertions, 11 deletions
diff --git a/addons/resource.language.en_gb/resources/strings.po b/addons/resource.language.en_gb/resources/strings.po index c00adcd9e3..43d66219b1 100644 --- a/addons/resource.language.en_gb/resources/strings.po +++ b/addons/resource.language.en_gb/resources/strings.po @@ -23765,6 +23765,24 @@ 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 "" +#. Title of "Allowed HDR dynamic metadata formats" setting +#: system/settings/settings.xml +msgctxt "#39198" +msgid "Allowed HDR dynamic metadata formats" +msgstr "" + +#. Help text for setting "Allowed HDR dynamic metadata formats" of label #39198 +#: system/settings/settings.xml +msgctxt "#39199" +msgid "Alters the video bitstream to remove dynamic HDR metadata. Select the HDR formats your device and display supports." +msgstr "" + +#. Label of Dolby Vision option for setting "Allowed HDR dynamic metadata formats" of label #39198 +#: system/settings/settings.xml +msgctxt "#39200" +msgid "Dolby Vision" +msgstr "" + # 40000 to 40800 are reserved for Video Versions feature #. Generic video versions label (plural) diff --git a/system/settings/settings.xml b/system/settings/settings.xml index dc80d94572..d38de29414 100755 --- a/system/settings/settings.xml +++ b/system/settings/settings.xml @@ -190,6 +190,21 @@ <default>false</default> <control type="toggle" /> </setting> + <setting id="videoplayer.allowedhdrformats" type="list[integer]" label="39198" help="39199"> + <requirement>HAS_MEDIACODEC</requirement> + <level>2</level> + <default>0</default> <!-- Allow all HDR formats --> + <constraints> + <options> + <option label="39200">0</option> <!-- Dolby Vision --> + </options> + <delimiter>,</delimiter> + </constraints> + <control type="list" format="string"> + <multiselect>true</multiselect> + <hidevalue>false</hidevalue> + </control> + </setting> </group> <group id="4" label="14232"> <setting id="videoplayer.stereoscopicplaybackmode" type="integer" label="36520" help="36537"> diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index afbce5ef63..d8c21558f7 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -23,8 +23,10 @@ #include "cores/VideoPlayer/VideoRenderers/RenderManager.h" #include "media/decoderfilter/DecoderFilterManager.h" #include "messaging/ApplicationMessenger.h" +#include "settings/SettingUtils.h" #include "settings/Settings.h" #include "settings/SettingsComponent.h" +#include "settings/lib/Setting.h" #include "utils/BitstreamConverter.h" #include "utils/BitstreamWriter.h" #include "utils/CPUInfo.h" @@ -501,8 +503,19 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio m_formatname = "amc-hevc"; const auto settings = CServiceBroker::GetSettingsComponent()->GetSettings(); - const bool convertDovi = - (settings) ? settings->GetBool(CSettings::SETTING_VIDEOPLAYER_CONVERTDOVI) : false; + bool convertDovi{false}; + bool removeDovi{false}; + + if (settings) + { + convertDovi = settings->GetBool(CSettings::SETTING_VIDEOPLAYER_CONVERTDOVI); + + const std::shared_ptr<CSettingList> allowedHdrFormatsSetting( + std::dynamic_pointer_cast<CSettingList>( + settings->GetSetting(CSettings::SETTING_VIDEOPLAYER_ALLOWEDHDRFORMATS))); + removeDovi = !CSettingUtils::FindIntInList( + allowedHdrFormatsSetting, CSettings::VIDEOPLAYER_ALLOWED_HDR_TYPE_DOLBY_VISION); + } bool isDvhe = (m_hints.codec_tag == MKTAG('d', 'v', 'h', 'e')); bool isDvh1 = (m_hints.codec_tag == MKTAG('d', 'v', 'h', '1')); @@ -517,7 +530,7 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio isDvhe = true; } - if (isDvhe || isDvh1) + if (!removeDovi && (isDvhe || isDvh1)) { bool displaySupportsDovi{false}; bool mediaCodecSupportsDovi{false}; @@ -589,15 +602,20 @@ 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) + if (m_bitstream) { - CLog::Log(LOGDEBUG, - "CDVDVideoCodecAndroidMediaCodec::Open Dolby Vision compatibility mode " - "enabled: {}", - convertDovi); + m_bitstream->SetRemoveDovi(removeDovi); - m_bitstream->SetConvertDovi(convertDovi); + // Only set for profile 7, container hint allows to skip parsing unnecessarily + if (m_hints.dovi.dv_profile == 7) + { + CLog::Log(LOGDEBUG, + "CDVDVideoCodecAndroidMediaCodec::Open Dolby Vision compatibility mode " + "enabled: {}", + convertDovi); + + m_bitstream->SetConvertDovi(convertDovi); + } } } diff --git a/xbmc/settings/Settings.h b/xbmc/settings/Settings.h index e58048ebfd..346c062a88 100644 --- a/xbmc/settings/Settings.h +++ b/xbmc/settings/Settings.h @@ -135,6 +135,7 @@ public: 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_VIDEOPLAYER_ALLOWEDHDRFORMATS = "videoplayer.allowedhdrformats"; static constexpr auto SETTING_MYVIDEOS_SELECTACTION = "myvideos.selectaction"; static constexpr auto SETTING_MYVIDEOS_SELECTDEFAULTVERSION = "myvideos.selectdefaultversion"; static constexpr auto SETTING_MYVIDEOS_PLAYACTION = "myvideos.playaction"; @@ -498,6 +499,9 @@ public: static constexpr int SETTING_AUTOPLAYNEXT_MOVIES = 3; static constexpr int SETTING_AUTOPLAYNEXT_UNCATEGORIZED = 4; + // values for SETTING_VIDEOPLAYER_ALLOWEDHDRFORMATS + static const int VIDEOPLAYER_ALLOWED_HDR_TYPE_DOLBY_VISION = 0; + /*! \brief Creates a new settings wrapper around a new settings manager. diff --git a/xbmc/utils/BitstreamConverter.cpp b/xbmc/utils/BitstreamConverter.cpp index 5fb96d4ed5..270e00cccc 100644 --- a/xbmc/utils/BitstreamConverter.cpp +++ b/xbmc/utils/BitstreamConverter.cpp @@ -356,6 +356,7 @@ CBitstreamConverter::CBitstreamConverter() m_sps_pps_context.sps_pps_data = NULL; m_start_decode = true; m_convert_dovi = false; + m_removeDovi = false; } CBitstreamConverter::~CBitstreamConverter() @@ -976,7 +977,10 @@ bool CBitstreamConverter::BitstreamConvert(uint8_t* pData, int iSize, uint8_t ** m_sps_pps_context.idr_sps_pps_seen = 0; } - if (m_convert_dovi) + if (m_removeDovi && (unit_type == HEVC_NAL_UNSPEC62 || unit_type == HEVC_NAL_UNSPEC63)) + write_buf = false; + + if (write_buf && m_convert_dovi) { if (unit_type == HEVC_NAL_UNSPEC62) { diff --git a/xbmc/utils/BitstreamConverter.h b/xbmc/utils/BitstreamConverter.h index 1920212a2a..25e5d650ba 100644 --- a/xbmc/utils/BitstreamConverter.h +++ b/xbmc/utils/BitstreamConverter.h @@ -100,6 +100,7 @@ public: void ResetStartDecode(void); bool CanStartDecode() const; void SetConvertDovi(bool value) { m_convert_dovi = value; } + void SetRemoveDovi(bool value) { m_removeDovi = value; } static bool mpeg2_sequence_header(const uint8_t *data, const uint32_t size, mpeg2_sequence *sequence); @@ -145,4 +146,5 @@ protected: AVCodecID m_codec; bool m_start_decode; bool m_convert_dovi; + bool m_removeDovi; }; |