1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Detect Dolby Vision as HDR

Co-Authored-By: Taloth <Taloth@users.noreply.github.com>

#5860
This commit is contained in:
Matt Evans 2021-02-03 12:19:22 +11:00 committed by Qstick
parent 6702c7d21b
commit d8c962a911
5 changed files with 32 additions and 13 deletions

View File

@ -8,20 +8,28 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
[TestFixture] [TestFixture]
public class FormatVideoDynamicRangeFixture : TestBase public class FormatVideoDynamicRangeFixture : TestBase
{ {
[TestCase(8, "BT.601 NTSC", "BT.709", "")] [TestCase(8, "", "", "", "", "")]
[TestCase(10, "BT.2020", "PQ", "HDR")] [TestCase(8, "BT.601 NTSC", "BT.709", "", "", "")]
[TestCase(8, "BT.2020", "PQ", "")] [TestCase(10, "BT.2020", "PQ", "", "", "HDR")]
[TestCase(10, "BT.601 NTSC", "PQ", "")] [TestCase(8, "BT.2020", "PQ", "", "", "")]
[TestCase(10, "BT.2020", "BT.709", "")] [TestCase(10, "BT.601 NTSC", "PQ", "", "", "")]
[TestCase(10, "BT.2020", "HLG", "HDR")] [TestCase(10, "BT.2020", "BT.709", "", "", "")]
public void should_format_video_dynamic_range(int bitDepth, string colourPrimaries, string transferCharacteristics, string expectedVideoDynamicRange) [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 var mediaInfo = new MediaInfoModel
{ {
VideoBitDepth = bitDepth, VideoBitDepth = bitDepth,
VideoColourPrimaries = colourPrimaries, VideoColourPrimaries = colourPrimaries,
VideoTransferCharacteristics = transferCharacteristics, VideoTransferCharacteristics = transferCharacteristics,
SchemaRevision = 5 VideoHdrFormat = hdrFormat,
VideoHdrFormatCompatibility = hdrFormatCompatibility,
SchemaRevision = 7
}; };
MediaInfoFormatter.FormatVideoDynamicRange(mediaInfo).Should().Be(expectedVideoDynamicRange); MediaInfoFormatter.FormatVideoDynamicRange(mediaInfo).Should().Be(expectedVideoDynamicRange);

View File

@ -65,6 +65,8 @@ public void get_info()
info.VideoColourPrimaries.Should().Be("BT.601 NTSC"); info.VideoColourPrimaries.Should().Be("BT.601 NTSC");
info.VideoTransferCharacteristics.Should().Be("BT.709"); info.VideoTransferCharacteristics.Should().Be("BT.709");
info.AudioAdditionalFeatures.Should().BeOneOf("", "LC"); info.AudioAdditionalFeatures.Should().BeOneOf("", "LC");
info.VideoHdrFormat.Should().BeEmpty();
info.VideoHdrFormatCompatibility.Should().BeEmpty();
} }
[Test] [Test]
@ -106,6 +108,8 @@ public void get_info_unicode()
info.VideoColourPrimaries.Should().Be("BT.601 NTSC"); info.VideoColourPrimaries.Should().Be("BT.601 NTSC");
info.VideoTransferCharacteristics.Should().Be("BT.709"); info.VideoTransferCharacteristics.Should().Be("BT.709");
info.AudioAdditionalFeatures.Should().BeOneOf("", "LC"); info.AudioAdditionalFeatures.Should().BeOneOf("", "LC");
info.VideoHdrFormat.Should().BeEmpty();
info.VideoHdrFormatCompatibility.Should().BeEmpty();
} }
[Test] [Test]

View File

@ -13,6 +13,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
public static class MediaInfoFormatter public static class MediaInfoFormatter
{ {
private const string ValidHdrColourPrimaries = "BT.2020"; private const string ValidHdrColourPrimaries = "BT.2020";
private const string VideoDynamicRangeHdr = "HDR";
private static readonly string[] ValidHdrTransferFunctions = { "PQ", "HLG" }; private static readonly string[] ValidHdrTransferFunctions = { "PQ", "HLG" };
private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(MediaInfoFormatter)); private static readonly Logger Logger = NzbDroneLogger.GetLogger(typeof(MediaInfoFormatter));
@ -602,8 +603,10 @@ private static string GetSceneNameMatch(string sceneName, params string[] tokens
public static string FormatVideoDynamicRange(MediaInfoModel mediaInfo) public static string FormatVideoDynamicRange(MediaInfoModel mediaInfo)
{ {
// assume SDR by default if (mediaInfo.VideoHdrFormat.IsNotNullOrWhiteSpace())
var videoDynamicRange = ""; {
return VideoDynamicRangeHdr;
}
if (mediaInfo.VideoBitDepth >= 10 && if (mediaInfo.VideoBitDepth >= 10 &&
mediaInfo.VideoColourPrimaries.IsNotNullOrWhiteSpace() && mediaInfo.VideoColourPrimaries.IsNotNullOrWhiteSpace() &&
@ -612,11 +615,11 @@ public static string FormatVideoDynamicRange(MediaInfoModel mediaInfo)
if (mediaInfo.VideoColourPrimaries.EqualsIgnoreCase(ValidHdrColourPrimaries) && if (mediaInfo.VideoColourPrimaries.EqualsIgnoreCase(ValidHdrColourPrimaries) &&
ValidHdrTransferFunctions.Any(mediaInfo.VideoTransferCharacteristics.Contains)) ValidHdrTransferFunctions.Any(mediaInfo.VideoTransferCharacteristics.Contains))
{ {
videoDynamicRange = "HDR"; return VideoDynamicRangeHdr;
} }
} }
return videoDynamicRange; return "";
} }
} }
} }

View File

@ -18,6 +18,8 @@ public class MediaInfoModel : IEmbeddedDocument
public int VideoMultiViewCount { get; set; } public int VideoMultiViewCount { get; set; }
public string VideoColourPrimaries { get; set; } public string VideoColourPrimaries { get; set; }
public string VideoTransferCharacteristics { get; set; } public string VideoTransferCharacteristics { get; set; }
public string VideoHdrFormat { get; set; }
public string VideoHdrFormatCompatibility { get; set; }
public int Width { get; set; } public int Width { get; set; }
public int Height { get; set; } public int Height { get; set; }
public string AudioFormat { get; set; } public string AudioFormat { get; set; }

View File

@ -19,7 +19,7 @@ public class VideoFileInfoReader : IVideoFileInfoReader
private readonly Logger _logger; private readonly Logger _logger;
public const int MINIMUM_MEDIA_INFO_SCHEMA_REVISION = 4; 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) public VideoFileInfoReader(IDiskProvider diskProvider, Logger logger)
{ {
@ -164,6 +164,8 @@ public MediaInfoModel GetMediaInfo(string filename)
VideoMultiViewCount = videoMultiViewCount, VideoMultiViewCount = videoMultiViewCount,
VideoColourPrimaries = mediaInfo.Get(StreamKind.Video, 0, "colour_primaries"), VideoColourPrimaries = mediaInfo.Get(StreamKind.Video, 0, "colour_primaries"),
VideoTransferCharacteristics = mediaInfo.Get(StreamKind.Video, 0, "transfer_characteristics"), 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, Height = height,
Width = width, Width = width,
AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"), AudioFormat = mediaInfo.Get(StreamKind.Audio, 0, "Format"),