Merge pull request #12534 from gnattu/new-tonemap-mode

Add new tonemap mode options
This commit is contained in:
Bond-009 2024-08-30 00:07:52 +02:00 committed by GitHub
commit 9644e894f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -66,6 +66,7 @@ namespace MediaBrowser.Controller.MediaEncoding
private readonly Version _minFFmpegReadrateOption = new Version(5, 0);
private readonly Version _minFFmpegWorkingVtHwSurface = new Version(7, 0, 1);
private readonly Version _minFFmpegDisplayRotationOption = new Version(6, 0);
private readonly Version _minFFmpegAdvancedTonemapMode = new Version(7, 0, 1);
private static readonly Regex _validationRegex = new(ValidationRegex, RegexOptions.Compiled);
@ -104,6 +105,9 @@ namespace MediaBrowser.Controller.MediaEncoding
"m4v",
};
private static readonly string[] _legacyTonemapModes = new[] { "max", "rgb" };
private static readonly string[] _advancedTonemapModes = new[] { "lum", "itp" };
// Set max transcoding channels for encoders that can't handle more than a set amount of channels
// AAC, FLAC, ALAC, libopus, libvorbis encoders all support at least 8 channels
private static readonly Dictionary<string, int> _audioTranscodeChannelLookup = new(StringComparer.OrdinalIgnoreCase)
@ -3294,14 +3298,16 @@ namespace MediaBrowser.Controller.MediaEncoding
{
args = "tonemap_{0}=format={1}:p=bt709:t=bt709:m=bt709:tonemap={2}:peak={3}:desat={4}";
if (string.Equals(options.TonemappingMode, "max", StringComparison.OrdinalIgnoreCase)
|| string.Equals(options.TonemappingMode, "rgb", StringComparison.OrdinalIgnoreCase))
{
if (_mediaEncoder.EncoderVersion >= _minFFmpegOclCuTonemapMode)
var useLegacyTonemapModes = _mediaEncoder.EncoderVersion >= _minFFmpegOclCuTonemapMode
&& _legacyTonemapModes.Contains(options.TonemappingMode, StringComparison.OrdinalIgnoreCase);
var useAdvancedTonemapModes = _mediaEncoder.EncoderVersion >= _minFFmpegAdvancedTonemapMode
&& _advancedTonemapModes.Contains(options.TonemappingMode, StringComparison.OrdinalIgnoreCase);
if (useLegacyTonemapModes || useAdvancedTonemapModes)
{
args += ":tonemap_mode={5}";
}
}
if (options.TonemappingParam != 0)
{