diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatVideoDynamicRangeFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatVideoDynamicRangeFixture.cs index e507f3e0c..897065906 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatVideoDynamicRangeFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatVideoDynamicRangeFixture.cs @@ -8,20 +8,28 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests [TestFixture] public class FormatVideoDynamicRangeFixture : TestBase { - [TestCase(8, "BT.601 NTSC", "BT.709", "")] - [TestCase(10, "BT.2020", "PQ", "HDR")] - [TestCase(8, "BT.2020", "PQ", "")] - [TestCase(10, "BT.601 NTSC", "PQ", "")] - [TestCase(10, "BT.2020", "BT.709", "")] - [TestCase(10, "BT.2020", "HLG", "HDR")] - public void should_format_video_dynamic_range(int bitDepth, string colourPrimaries, string transferCharacteristics, string expectedVideoDynamicRange) + [TestCase(8, "", "", "", "", "")] + [TestCase(8, "BT.601 NTSC", "BT.709", "", "", "")] + [TestCase(10, "BT.2020", "PQ", "", "", "HDR")] + [TestCase(8, "BT.2020", "PQ", "", "", "")] + [TestCase(10, "BT.601 NTSC", "PQ", "", "", "")] + [TestCase(10, "BT.2020", "BT.709", "", "", "")] + [TestCase(10, "BT.2020", "HLG", "", "", "HDR")] + [TestCase(10, "", "", "Dolby Vision", "", "HDR")] + [TestCase(10, "", "", "SMPTE ST 2086", "HDR10", "HDR")] + [TestCase(8, "", "", "Dolby Vision", "", "HDR")] + [TestCase(8, "", "", "SMPTE ST 2086", "HDR10", "HDR")] + [TestCase(10, "BT.2020", "PQ", "Dolby Vision / SMPTE ST 2086", "Blu-ray / HDR10", "HDR")] + public void should_format_video_dynamic_range(int bitDepth, string colourPrimaries, string transferCharacteristics, string hdrFormat, string hdrFormatCompatibility, string expectedVideoDynamicRange) { var mediaInfo = new MediaInfoModel { VideoBitDepth = bitDepth, VideoColourPrimaries = colourPrimaries, VideoTransferCharacteristics = transferCharacteristics, - SchemaRevision = 5 + VideoHdrFormat = hdrFormat, + VideoHdrFormatCompatibility = hdrFormatCompatibility, + SchemaRevision = 7 }; MediaInfoFormatter.FormatVideoDynamicRange(mediaInfo).Should().Be(expectedVideoDynamicRange); diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs index 602c96310..946efbf62 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/VideoFileInfoReaderFixture.cs @@ -65,6 +65,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo info.VideoColourPrimaries.Should().Be("BT.601 NTSC"); info.VideoTransferCharacteristics.Should().Be("BT.709"); info.AudioAdditionalFeatures.Should().BeOneOf("", "LC"); + info.VideoHdrFormat.Should().BeEmpty(); + info.VideoHdrFormatCompatibility.Should().BeEmpty(); } [Test] @@ -106,6 +108,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo info.VideoColourPrimaries.Should().Be("BT.601 NTSC"); info.VideoTransferCharacteristics.Should().Be("BT.709"); info.AudioAdditionalFeatures.Should().BeOneOf("", "LC"); + info.VideoHdrFormat.Should().BeEmpty(); + info.VideoHdrFormatCompatibility.Should().BeEmpty(); } [Test] diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs index 4de9cd393..168d11853 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs @@ -13,6 +13,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo public static class MediaInfoFormatter { private const string ValidHdrColourPrimaries = "BT.2020"; + private const string VideoDynamicRangeHdr = "HDR"; private static readonly string[] ValidHdrTransferFunctions = { "PQ", "HLG" }; private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(MediaInfoFormatter)); @@ -602,8 +603,10 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo public static string FormatVideoDynamicRange(MediaInfoModel mediaInfo) { - // assume SDR by default - var videoDynamicRange = ""; + if (mediaInfo.VideoHdrFormat.IsNotNullOrWhiteSpace()) + { + return VideoDynamicRangeHdr; + } if (mediaInfo.VideoBitDepth >= 10 && mediaInfo.VideoColourPrimaries.IsNotNullOrWhiteSpace() && @@ -612,11 +615,11 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo if (mediaInfo.VideoColourPrimaries.EqualsIgnoreCase(ValidHdrColourPrimaries) && ValidHdrTransferFunctions.Any(mediaInfo.VideoTransferCharacteristics.Contains)) { - videoDynamicRange = "HDR"; + return VideoDynamicRangeHdr; } } - return videoDynamicRange; + return ""; } } } diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs index 088c8c908..0f398de99 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs @@ -18,6 +18,8 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo public int VideoMultiViewCount { get; set; } public string VideoColourPrimaries { get; set; } public string VideoTransferCharacteristics { get; set; } + public string VideoHdrFormat { get; set; } + public string VideoHdrFormatCompatibility { get; set; } public int Width { get; set; } public int Height { get; set; } public string AudioFormat { get; set; } diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs index f848469cb..650d58eeb 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs @@ -19,7 +19,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo private readonly Logger _logger; public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 4; - public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 6; + public const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 7; public VideoFileInfoReader(IDiskProvider diskProvider, Logger logger) { @@ -164,6 +164,8 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo VideoMultiViewCount = videoMultiViewCount, VideoColourPrimaries = mediaInfo.Get(StreamKind.Video, 0, "colour_primaries"), VideoTransferCharacteristics = mediaInfo.Get(StreamKind.Video, 0, "transfer_characteristics"), + VideoHdrFormat = mediaInfo.Get(StreamKind.Video, 0, "HDR_Format"), + VideoHdrFormatCompatibility = mediaInfo.Get(StreamKind.Video, 0, "HDR_Format_Compatibility"), Height = height, Width = width, AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),