Merge pull request #7964 from jellyfin/dovi-side-data
(cherry picked from commit 39d185c7b19ed2da1ae46566152fb1cf182266cd) Signed-off-by: Joshua Boniface <joshua@boniface.me>
This commit is contained in:
parent
e61c80fed7
commit
fe32b5e333
|
@ -170,7 +170,15 @@ namespace Emby.Server.Implementations.Data
|
|||
"CodecTimeBase",
|
||||
"ColorPrimaries",
|
||||
"ColorSpace",
|
||||
"ColorTransfer"
|
||||
"ColorTransfer",
|
||||
"DvVersionMajor",
|
||||
"DvVersionMinor",
|
||||
"DvProfile",
|
||||
"DvLevel",
|
||||
"RpuPresentFlag",
|
||||
"ElPresentFlag",
|
||||
"BlPresentFlag",
|
||||
"DvBlSignalCompatibilityId"
|
||||
};
|
||||
|
||||
private static readonly string _mediaStreamSaveColumnsInsertQuery =
|
||||
|
@ -341,7 +349,7 @@ namespace Emby.Server.Implementations.Data
|
|||
public void Initialize(SqliteUserDataRepository userDataRepo, IUserManager userManager)
|
||||
{
|
||||
const string CreateMediaStreamsTableCommand
|
||||
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, ColorPrimaries TEXT NULL, ColorSpace TEXT NULL, ColorTransfer TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
|
||||
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, ColorPrimaries TEXT NULL, ColorSpace TEXT NULL, ColorTransfer TEXT NULL, DvVersionMajor INT NULL, DvVersionMinor INT NULL, DvProfile INT NULL, DvLevel INT NULL, RpuPresentFlag INT NULL, ElPresentFlag INT NULL, BlPresentFlag INT NULL, DvBlSignalCompatibilityId INT NULL, PRIMARY KEY (ItemId, StreamIndex))";
|
||||
const string CreateMediaAttachmentsTableCommand
|
||||
= "create table if not exists mediaattachments (ItemId GUID, AttachmentIndex INT, Codec TEXT, CodecTag TEXT NULL, Comment TEXT NULL, Filename TEXT NULL, MIMEType TEXT NULL, PRIMARY KEY (ItemId, AttachmentIndex))";
|
||||
|
||||
|
@ -555,6 +563,15 @@ namespace Emby.Server.Implementations.Data
|
|||
AddColumn(db, "MediaStreams", "ColorPrimaries", "TEXT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "ColorSpace", "TEXT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "ColorTransfer", "TEXT", existingColumnNames);
|
||||
|
||||
AddColumn(db, "MediaStreams", "DvVersionMajor", "INT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "DvVersionMinor", "INT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "DvProfile", "INT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "DvLevel", "INT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "RpuPresentFlag", "INT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "ElPresentFlag", "INT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "BlPresentFlag", "INT", existingColumnNames);
|
||||
AddColumn(db, "MediaStreams", "DvBlSignalCompatibilityId", "INT", existingColumnNames);
|
||||
},
|
||||
TransactionMode);
|
||||
|
||||
|
@ -5859,6 +5876,15 @@ AND Type = @InternalPersonType)");
|
|||
statement.TryBind("@ColorPrimaries" + index, stream.ColorPrimaries);
|
||||
statement.TryBind("@ColorSpace" + index, stream.ColorSpace);
|
||||
statement.TryBind("@ColorTransfer" + index, stream.ColorTransfer);
|
||||
|
||||
statement.TryBind("@DvVersionMajor" + index, stream.DvVersionMajor);
|
||||
statement.TryBind("@DvVersionMinor" + index, stream.DvVersionMinor);
|
||||
statement.TryBind("@DvProfile" + index, stream.DvProfile);
|
||||
statement.TryBind("@DvLevel" + index, stream.DvLevel);
|
||||
statement.TryBind("@RpuPresentFlag" + index, stream.RpuPresentFlag);
|
||||
statement.TryBind("@ElPresentFlag" + index, stream.ElPresentFlag);
|
||||
statement.TryBind("@BlPresentFlag" + index, stream.BlPresentFlag);
|
||||
statement.TryBind("@DvBlSignalCompatibilityId" + index, stream.DvBlSignalCompatibilityId);
|
||||
}
|
||||
|
||||
statement.Reset();
|
||||
|
@ -6030,6 +6056,46 @@ AND Type = @InternalPersonType)");
|
|||
item.ColorTransfer = colorTransfer;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(35, out var dvVersionMajor))
|
||||
{
|
||||
item.DvVersionMajor = dvVersionMajor;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(36, out var dvVersionMinor))
|
||||
{
|
||||
item.DvVersionMinor = dvVersionMinor;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(37, out var dvProfile))
|
||||
{
|
||||
item.DvProfile = dvProfile;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(38, out var dvLevel))
|
||||
{
|
||||
item.DvLevel = dvLevel;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(39, out var rpuPresentFlag))
|
||||
{
|
||||
item.RpuPresentFlag = rpuPresentFlag;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(40, out var elPresentFlag))
|
||||
{
|
||||
item.ElPresentFlag = elPresentFlag;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(41, out var blPresentFlag))
|
||||
{
|
||||
item.BlPresentFlag = blPresentFlag;
|
||||
}
|
||||
|
||||
if (reader.TryGetInt32(42, out var dvBlSignalCompatibilityId))
|
||||
{
|
||||
item.DvBlSignalCompatibilityId = dvBlSignalCompatibilityId;
|
||||
}
|
||||
|
||||
if (item.Type == MediaStreamType.Subtitle)
|
||||
{
|
||||
item.LocalizedUndefined = _localization.GetLocalizedString("Undefined");
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -310,5 +310,12 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
/// <value>The color primaries.</value>
|
||||
[JsonPropertyName("color_primaries")]
|
||||
public string ColorPrimaries { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the side_data_list.
|
||||
/// </summary>
|
||||
/// <value>The side_data_list.</value>
|
||||
[JsonPropertyName("side_data_list")]
|
||||
public IReadOnlyList<MediaStreamInfoSideData> SideDataList { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace MediaBrowser.MediaEncoding.Probing
|
||||
{
|
||||
/// <summary>
|
||||
/// Class MediaStreamInfoSideData.
|
||||
/// </summary>
|
||||
public class MediaStreamInfoSideData
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the SideDataType.
|
||||
/// </summary>
|
||||
/// <value>The SideDataType.</value>
|
||||
[JsonPropertyName("side_data_type")]
|
||||
public string? SideDataType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DvVersionMajor.
|
||||
/// </summary>
|
||||
/// <value>The DvVersionMajor.</value>
|
||||
[JsonPropertyName("dv_version_major")]
|
||||
public int? DvVersionMajor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DvVersionMinor.
|
||||
/// </summary>
|
||||
/// <value>The DvVersionMinor.</value>
|
||||
[JsonPropertyName("dv_version_minor")]
|
||||
public int? DvVersionMinor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DvProfile.
|
||||
/// </summary>
|
||||
/// <value>The DvProfile.</value>
|
||||
[JsonPropertyName("dv_profile")]
|
||||
public int? DvProfile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DvLevel.
|
||||
/// </summary>
|
||||
/// <value>The DvLevel.</value>
|
||||
[JsonPropertyName("dv_level")]
|
||||
public int? DvLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RpuPresentFlag.
|
||||
/// </summary>
|
||||
/// <value>The RpuPresentFlag.</value>
|
||||
[JsonPropertyName("rpu_present_flag")]
|
||||
public int? RpuPresentFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ElPresentFlag.
|
||||
/// </summary>
|
||||
/// <value>The ElPresentFlag.</value>
|
||||
[JsonPropertyName("el_present_flag")]
|
||||
public int? ElPresentFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the BlPresentFlag.
|
||||
/// </summary>
|
||||
/// <value>The BlPresentFlag.</value>
|
||||
[JsonPropertyName("bl_present_flag")]
|
||||
public int? BlPresentFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the DvBlSignalCompatibilityId.
|
||||
/// </summary>
|
||||
/// <value>The DvBlSignalCompatibilityId.</value>
|
||||
[JsonPropertyName("dv_bl_signal_compatibility_id")]
|
||||
public int? DvBlSignalCompatibilityId { get; set; }
|
||||
}
|
||||
}
|
|
@ -841,6 +841,27 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
{
|
||||
stream.ColorPrimaries = streamInfo.ColorPrimaries;
|
||||
}
|
||||
|
||||
if (streamInfo.SideDataList != null)
|
||||
{
|
||||
foreach (var data in streamInfo.SideDataList)
|
||||
{
|
||||
// Parse Dolby Vision metadata from side_data
|
||||
if (string.Equals(data.SideDataType, "DOVI configuration record", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
stream.DvVersionMajor = data.DvVersionMajor;
|
||||
stream.DvVersionMinor = data.DvVersionMinor;
|
||||
stream.DvProfile = data.DvProfile;
|
||||
stream.DvLevel = data.DvLevel;
|
||||
stream.RpuPresentFlag = data.RpuPresentFlag;
|
||||
stream.ElPresentFlag = data.ElPresentFlag;
|
||||
stream.BlPresentFlag = data.BlPresentFlag;
|
||||
stream.DvBlSignalCompatibilityId = data.DvBlSignalCompatibilityId;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -72,6 +72,54 @@ namespace MediaBrowser.Model.Entities
|
|||
/// <value>The color primaries.</value>
|
||||
public string ColorPrimaries { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision version major.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision version major.</value>
|
||||
public int? DvVersionMajor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision version minor.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision version minor.</value>
|
||||
public int? DvVersionMinor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision profile.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision profile.</value>
|
||||
public int? DvProfile { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision level.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision level.</value>
|
||||
public int? DvLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision rpu present flag.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision rpu present flag.</value>
|
||||
public int? RpuPresentFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision el present flag.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision el present flag.</value>
|
||||
public int? ElPresentFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision bl present flag.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision bl present flag.</value>
|
||||
public int? BlPresentFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Dolby Vision bl signal compatibility id.
|
||||
/// </summary>
|
||||
/// <value>The Dolby Vision bl signal compatibility id.</value>
|
||||
public int? DvBlSignalCompatibilityId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the comment.
|
||||
/// </summary>
|
||||
|
@ -124,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; }
|
||||
|
@ -582,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))
|
||||
|
|
|
@ -75,6 +75,14 @@ namespace Jellyfin.MediaEncoding.Tests.Probing
|
|||
Assert.Equal(1, res.VideoStream.RefFrames);
|
||||
Assert.Equal("1/1000", res.VideoStream.TimeBase);
|
||||
Assert.Equal(MediaStreamType.Video, res.VideoStream.Type);
|
||||
Assert.Equal(1, res.VideoStream.DvVersionMajor);
|
||||
Assert.Equal(0, res.VideoStream.DvVersionMinor);
|
||||
Assert.Equal(5, res.VideoStream.DvProfile);
|
||||
Assert.Equal(6, res.VideoStream.DvLevel);
|
||||
Assert.Equal(1, res.VideoStream.RpuPresentFlag);
|
||||
Assert.Equal(0, res.VideoStream.ElPresentFlag);
|
||||
Assert.Equal(1, res.VideoStream.BlPresentFlag);
|
||||
Assert.Equal(0, res.VideoStream.DvBlSignalCompatibilityId);
|
||||
|
||||
Assert.Empty(res.Chapters);
|
||||
Assert.Equal("Just color bars", res.Overview);
|
||||
|
|
|
@ -47,7 +47,20 @@
|
|||
"tags": {
|
||||
"ENCODER": "Lavc57.107.100 libx264",
|
||||
"DURATION": "00:00:01.000000000"
|
||||
}
|
||||
},
|
||||
"side_data_list": [
|
||||
{
|
||||
"side_data_type": "DOVI configuration record",
|
||||
"dv_version_major": 1,
|
||||
"dv_version_minor": 0,
|
||||
"dv_profile": 5,
|
||||
"dv_level": 6,
|
||||
"rpu_present_flag": 1,
|
||||
"el_present_flag": 0,
|
||||
"bl_present_flag": 1,
|
||||
"dv_bl_signal_compatibility_id": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"chapters": [
|
||||
|
|
Loading…
Reference in New Issue
Block a user