Merge pull request #9642 from nyanmisaka/tonemap-mode-selection

Fix the brightness of VPP tonemap and add the tonemap mode
This commit is contained in:
Cody Robibero 2023-04-14 14:58:19 -06:00 committed by GitHub
commit d5a8419bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 11 deletions

View File

@ -43,6 +43,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private readonly Version _minFFmpegImplictHwaccel = new Version(6, 0);
private readonly Version _minFFmpegHwaUnsafeOutput = new Version(6, 0);
private readonly Version _minFFmpegOclCuTonemapMode = new Version(5, 1, 3);
private static readonly string[] _videoProfilesH264 = new[]
{
@ -2816,7 +2817,7 @@ namespace MediaBrowser.Controller.MediaEncoding
return string.Empty;
}
public static string GetHwTonemapFilter(EncodingOptions options, string hwTonemapSuffix, string videoFormat)
public string GetHwTonemapFilter(EncodingOptions options, string hwTonemapSuffix, string videoFormat)
{
if (string.IsNullOrEmpty(hwTonemapSuffix))
{
@ -2827,7 +2828,8 @@ namespace MediaBrowser.Controller.MediaEncoding
if (hwTonemapSuffix.Contains("vaapi", StringComparison.OrdinalIgnoreCase))
{
args += ",procamp_vaapi=b={2}:c={3}:extra_hw_frames=16";
args = "procamp_vaapi=b={2}:c={3}," + args + ":extra_hw_frames=32";
return string.Format(
CultureInfo.InvariantCulture,
args,
@ -2840,14 +2842,24 @@ namespace MediaBrowser.Controller.MediaEncoding
{
args += ":tonemap={2}:peak={3}:desat={4}";
if (options.TonemappingParam != 0)
if (string.Equals(options.TonemappingMode, "max", StringComparison.OrdinalIgnoreCase)
|| string.Equals(options.TonemappingMode, "rgb", StringComparison.OrdinalIgnoreCase))
{
args += ":param={5}";
if (_mediaEncoder.EncoderVersion >= _minFFmpegOclCuTonemapMode)
{
args += ":tonemap_mode={5}";
}
}
if (!string.Equals(options.TonemappingRange, "auto", StringComparison.OrdinalIgnoreCase))
if (options.TonemappingParam != 0)
{
args += ":range={6}";
args += ":param={6}";
}
if (string.Equals(options.TonemappingRange, "tv", StringComparison.OrdinalIgnoreCase)
|| string.Equals(options.TonemappingRange, "pc", StringComparison.OrdinalIgnoreCase))
{
args += ":range={7}";
}
}
@ -2859,6 +2871,7 @@ namespace MediaBrowser.Controller.MediaEncoding
options.TonemappingAlgorithm,
options.TonemappingPeak,
options.TonemappingDesat,
options.TonemappingMode,
options.TonemappingParam,
options.TonemappingRange);
}

View File

@ -21,13 +21,13 @@ namespace MediaBrowser.Model.Configuration
EnableTonemapping = false;
EnableVppTonemapping = false;
TonemappingAlgorithm = "bt2390";
TonemappingMode = "auto";
TonemappingRange = "auto";
TonemappingDesat = 0;
TonemappingThreshold = 0.8;
TonemappingPeak = 100;
TonemappingParam = 0;
VppTonemappingBrightness = 0;
VppTonemappingContrast = 1.2;
VppTonemappingBrightness = 16;
VppTonemappingContrast = 1;
H264Crf = 23;
H265Crf = 28;
DeinterlaceDoubleRate = false;
@ -82,12 +82,12 @@ namespace MediaBrowser.Model.Configuration
public string TonemappingAlgorithm { get; set; }
public string TonemappingMode { get; set; }
public string TonemappingRange { get; set; }
public double TonemappingDesat { get; set; }
public double TonemappingThreshold { get; set; }
public double TonemappingPeak { get; set; }
public double TonemappingParam { get; set; }