From 0282f847d57567054afef72b4d93256c7d3c52ca Mon Sep 17 00:00:00 2001 From: fandangos Date: Mon, 21 Dec 2020 18:43:58 -0300 Subject: [PATCH] Add support for Matroska DolbyVision This commit adds support to Dolby Vision combined layer present on mkv files --- tools/depends/target/ffmpeg/FFMPEG-VERSION | 4 ++-- .../Video/DVDVideoCodecAndroidMediaCodec.cpp | 6 ++++++ .../VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tools/depends/target/ffmpeg/FFMPEG-VERSION b/tools/depends/target/ffmpeg/FFMPEG-VERSION index 9017251829b95..8aef640715408 100644 --- a/tools/depends/target/ffmpeg/FFMPEG-VERSION +++ b/tools/depends/target/ffmpeg/FFMPEG-VERSION @@ -1,4 +1,4 @@ LIBNAME=ffmpeg -BASE_URL=https://github.com/xbmc/FFmpeg -VERSION=4.3.1-Matrix-Beta1 +BASE_URL=https://github.com/fandangos/FFmpeg +VERSION=4.3.1-Matrix-DV1 ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp index 268697cb09bce..2095f428ba3b3 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecAndroidMediaCodec.cpp @@ -498,6 +498,12 @@ bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptio m_mime = "video/dolby-vision"; m_formatname = "amc-dvh1"; } + else if (m_hints.codec_tag == MKBETAG('d', 'v', 'v', 'C') || + m_hints.codec_tag == MKBETAG('d', 'v', 'c', 'C')) + { + m_mime = "video/dolby-vision"; + m_formatname = "amc-dvh1"; + } else { m_mime = "video/hevc"; diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp index ff13cad28de50..a208e01c8a6a7 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp @@ -47,6 +47,7 @@ #endif extern "C" { +#include "libavutil/dovi_meta.h" #include #include } @@ -1629,7 +1630,20 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx) stereoMode = GetStereoModeFromMetadata(m_pFormatContext->metadata); if (!stereoMode.empty()) st->stereo_mode = stereoMode; - + + if (m_bMatroska) + { + int size; + uint8_t* side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_DOVI_CONF, &size); + if (size > 0 && side_data) + { + auto dovi = reinterpret_cast(side_data); + if (dovi->dv_profile > 7) + pStream->codecpar->codec_tag = MKBETAG('d', 'v', 'v', 'C'); + else + pStream->codecpar->codec_tag = MKBETAG('d', 'v', 'c', 'C'); + } + } if (m_pInput->IsStreamType(DVDSTREAM_TYPE_DVD)) {