feat: separate videotoolbox tone mapping option

Signed-off-by: gnattu <gnattuoc@me.com>
This commit is contained in:
gnattu 2024-02-16 00:16:59 +08:00
parent cf3e3e2c3d
commit 5c743f2b4d
2 changed files with 18 additions and 1 deletions

View File

@ -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;
}
/// <summary>
/// Gets the name of the output video codec.
/// </summary>
@ -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);

View File

@ -146,6 +146,11 @@ public class EncodingOptions
/// </summary>
public bool EnableVppTonemapping { get; set; }
/// <summary>
/// Gets or sets a value indicating whether videotoolbox tonemapping is enabled.
/// </summary>
public bool EnableVideoToolboxTonemapping { get; set; }
/// <summary>
/// Gets or sets the tone-mapping algorithm.
/// </summary>