From 5c743f2b4d242b9b9ea438b2331439f58a92c447 Mon Sep 17 00:00:00 2001 From: gnattu Date: Fri, 16 Feb 2024 00:16:59 +0800 Subject: [PATCH] feat: separate videotoolbox tone mapping option Signed-off-by: gnattu --- .../MediaEncoding/EncodingHelper.cs | 14 +++++++++++++- .../Configuration/EncodingOptions.cs | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index d23eb00fea..62799f01e1 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -309,6 +309,18 @@ namespace MediaBrowser.Controller.MediaEncoding && state.VideoStream.VideoRangeType == VideoRangeType.HDR10; } + private bool IsVideoToolboxVppTonemapAvailable(EncodingJobInfo state, EncodingOptions options) + { + if (state.VideoStream is null + || !options.EnableVideoToolboxTonemapping + || GetVideoColorBitDepth(state) != 10) + { + return false; + } + return state.VideoStream.VideoRange == VideoRange.HDR + && state.VideoStream.VideoRangeType == VideoRangeType.HDR10; + } + /// /// Gets the name of the output video codec. /// @@ -4991,7 +5003,7 @@ namespace MediaBrowser.Controller.MediaEncoding var supportsHwDeint = _mediaEncoder.SupportsFilter("yadif_videotoolbox"); var supportsHwScale = _mediaEncoder.SupportsFilter("scale_vt"); // VideoToolbox is special. It does not use a separate tone mapping filter like others. Instead, it performs both tone mapping and scaling in a single filter. - var useHwToneMapping = IsHwTonemapAvailable(state, options) && supportsHwScale; + var useHwToneMapping = IsVideoToolboxVppTonemapAvailable(state, options) && supportsHwScale; // fallback to software filters if we are using filters not supported by hardware yet. var useHardwareFilters = noOverlay && (!doDeintH2645 || supportsHwDeint); diff --git a/MediaBrowser.Model/Configuration/EncodingOptions.cs b/MediaBrowser.Model/Configuration/EncodingOptions.cs index 84c735f9ca..13ebebded4 100644 --- a/MediaBrowser.Model/Configuration/EncodingOptions.cs +++ b/MediaBrowser.Model/Configuration/EncodingOptions.cs @@ -146,6 +146,11 @@ public class EncodingOptions /// public bool EnableVppTonemapping { get; set; } + /// + /// Gets or sets a value indicating whether videotoolbox tonemapping is enabled. + /// + public bool EnableVideoToolboxTonemapping { get; set; } + /// /// Gets or sets the tone-mapping algorithm. ///