Add VideoDoViTitle to display DV compatibility

This commit is contained in:
nyanmisaka 2022-06-24 22:30:49 +08:00
parent e931f5a32b
commit 50bc41d84d
2 changed files with 61 additions and 12 deletions

View File

@ -157,9 +157,9 @@ namespace MediaBrowser.Controller.MediaEncoding
return false;
}
if (string.Equals(state.VideoStream.CodecTag, "dovi", StringComparison.OrdinalIgnoreCase)
|| string.Equals(state.VideoStream.CodecTag, "dvh1", StringComparison.OrdinalIgnoreCase)
|| string.Equals(state.VideoStream.CodecTag, "dvhe", StringComparison.OrdinalIgnoreCase))
if (string.Equals(state.VideoStream.Codec, "hevc", StringComparison.OrdinalIgnoreCase)
&& string.Equals(state.VideoStream.VideoRange, "HDR", StringComparison.OrdinalIgnoreCase)
&& string.Equals(state.VideoStream.VideoRangeType, "DOVI", StringComparison.OrdinalIgnoreCase))
{
// Only native SW decoder and HW accelerator can parse dovi rpu.
var vidDecoder = GetHardwareVideoDecoder(state, options) ?? string.Empty;
@ -170,22 +170,24 @@ namespace MediaBrowser.Controller.MediaEncoding
return isSwDecoder || isNvdecDecoder || isVaapiDecoder || isD3d11vaDecoder;
}
return string.Equals(state.VideoStream.ColorTransfer, "smpte2084", StringComparison.OrdinalIgnoreCase)
|| string.Equals(state.VideoStream.ColorTransfer, "arib-std-b67", StringComparison.OrdinalIgnoreCase);
return string.Equals(state.VideoStream.VideoRange, "HDR", StringComparison.OrdinalIgnoreCase)
&& (string.Equals(state.VideoStream.VideoRangeType, "HDR10", StringComparison.OrdinalIgnoreCase)
|| string.Equals(state.VideoStream.VideoRangeType, "HLG", StringComparison.OrdinalIgnoreCase));
}
private bool IsVaapiVppTonemapAvailable(EncodingJobInfo state, EncodingOptions options)
{
if (state.VideoStream == null)
if (state.VideoStream == null
|| !options.EnableVppTonemapping
|| GetVideoColorBitDepth(state) != 10)
{
return false;
}
// Native VPP tonemapping may come to QSV in the future.
return options.EnableVppTonemapping
&& string.Equals(state.VideoStream.ColorTransfer, "smpte2084", StringComparison.OrdinalIgnoreCase)
&& GetVideoColorBitDepth(state) == 10;
return string.Equals(state.VideoStream.VideoRange, "HDR", StringComparison.OrdinalIgnoreCase)
&& string.Equals(state.VideoStream.VideoRangeType, "HDR10", StringComparison.OrdinalIgnoreCase);
}
/// <summary>

View File

@ -172,6 +172,47 @@ namespace MediaBrowser.Model.Entities
}
}
/// <summary>
/// Gets the video dovi title.
/// </summary>
/// <value>The video dovi title.</value>
public string VideoDoViTitle
{
get
{
var dvProfile = DvProfile;
var rpuPresentFlag = RpuPresentFlag == 1;
var blPresentFlag = BlPresentFlag == 1;
var dvBlCompatId = DvBlSignalCompatibilityId;
if (rpuPresentFlag
&& blPresentFlag
&& (dvProfile == 4
|| dvProfile == 5
|| dvProfile == 7
|| dvProfile == 8
|| dvProfile == 9))
{
var title = "DV Profile " + dvProfile;
if (dvBlCompatId > 0)
{
title += "." + dvBlCompatId;
}
return dvBlCompatId switch
{
1 => title + " (HDR10)",
2 => title + " (SDR)",
4 => title + " (HLG)",
_ => title
};
}
return null;
}
}
public string LocalizedUndefined { get; set; }
public string LocalizedDefault { get; set; }
@ -630,11 +671,17 @@ namespace MediaBrowser.Model.Entities
return ("HDR", "HLG");
}
// For some Dolby Vision files, no color transfer is provided, so check the codec
var codecTag = CodecTag;
var dvProfile = DvProfile;
var rpuPresentFlag = RpuPresentFlag == 1;
var blPresentFlag = BlPresentFlag == 1;
var dvBlCompatId = DvBlSignalCompatibilityId;
if (string.Equals(codecTag, "dovi", StringComparison.OrdinalIgnoreCase)
var isDoViHDRProfile = dvProfile == 5 || dvProfile == 7 || dvProfile == 8;
var isDoViHDRFlag = rpuPresentFlag && blPresentFlag && (dvBlCompatId == 0 || dvBlCompatId == 1 || dvBlCompatId == 4);
if ((isDoViHDRProfile && isDoViHDRFlag)
|| string.Equals(codecTag, "dovi", StringComparison.OrdinalIgnoreCase)
|| string.Equals(codecTag, "dvh1", StringComparison.OrdinalIgnoreCase)
|| string.Equals(codecTag, "dvhe", StringComparison.OrdinalIgnoreCase)
|| string.Equals(codecTag, "dav1", StringComparison.OrdinalIgnoreCase))