mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
using ErsatzTV.FFmpeg.Format; |
|
|
|
namespace ErsatzTV.FFmpeg.Filter; |
|
|
|
public class TonemapFilter : BaseFilter |
|
{ |
|
private readonly FrameState _currentState; |
|
private readonly IPixelFormat _desiredPixelFormat; |
|
|
|
public TonemapFilter(FrameState currentState, IPixelFormat desiredPixelFormat) |
|
{ |
|
_currentState = currentState; |
|
_desiredPixelFormat = desiredPixelFormat; |
|
} |
|
|
|
public override string Filter |
|
{ |
|
get |
|
{ |
|
string pixelFormat = _currentState.PixelFormat.Match(pf => pf.FFmpegName, () => string.Empty); |
|
|
|
var tonemap = |
|
$"setparams=colorspace=bt2020c,zscale=transfer=linear,tonemap=hable,zscale=transfer=bt709,format={_desiredPixelFormat.FFmpegName}"; |
|
|
|
if (_currentState.FrameDataLocation == FrameDataLocation.Hardware) |
|
{ |
|
if (!string.IsNullOrWhiteSpace(pixelFormat)) |
|
{ |
|
return $"hwdownload,format={pixelFormat},{tonemap}"; |
|
} |
|
|
|
return $"hwdownload,{tonemap}"; |
|
} |
|
|
|
return tonemap; |
|
} |
|
} |
|
|
|
public override FrameState NextState(FrameState currentState) => |
|
currentState with |
|
{ |
|
PixelFormat = Some(_desiredPixelFormat), |
|
FrameDataLocation = FrameDataLocation.Software |
|
}; |
|
}
|
|
|