public SuperRes() { TargetSize = () => Renderer.TargetSize; m_ShiftedScaler = new Scaler.Custom(new ShiftedScaler(0.5f), ScalerTaps.Six, false); Passes = 3; Strength = 0.75f; Sharpness = 0.5f; AntiAliasing = 0.25f; AntiRinging = 0.75f; UseNEDI = false; FirstPassOnly = false; upscaler = new Scaler.Jinc(ScalerTaps.Four, false); downscaler = new Scaler.Bilinear(); }
public override IFilter CreateFilter(IResizeableFilter sourceFilter) { var upscaler = new Scaler.Custom(new GaussianBlur(0.75), ScalerTaps.Four, false); var downscaler = new Scaler.HwBilinear(); // Good enough (?) int bits = 8; switch (Renderer.InputFormat) { case FrameBufferInputFormat.P010: bits = 10; break; case FrameBufferInputFormat.Y410: bits = 10; break; case FrameBufferInputFormat.P016: bits = 16; break; case FrameBufferInputFormat.Y416: bits = 16; break; case FrameBufferInputFormat.Rgb24: return(sourceFilter); case FrameBufferInputFormat.Rgb32: return(sourceFilter); } if (bits > maxbitdepth) { return(sourceFilter); } var inputsize = sourceFilter.OutputSize; var size = inputsize; var current = sourceFilter.ConvertToYuv(); var factor = 2.0; var downscaled = new Stack <IFilter>(); downscaled.Push(current); // Generate downscaled images for (int i = 0; i < 8; i++) { size = new Size((int)Math.Floor(size.Width / factor), (int)Math.Floor(size.Height / factor)); if (size.Width == 0 || size.Height == 0) { break; } current = new ResizeFilter(current, size, upscaler, downscaler); downscaled.Push(current); } var deband = downscaled.Pop(); while (downscaled.Count > 0) { deband = new ShaderFilter(CompileShader("Deband.hlsl"), true, new[] { (1 << bits) - 1, advancedMode ? threshold : DEFAULT_THRESHOLD, advancedMode ? margin : DEFAULT_MARGIN }, downscaled.Pop(), deband); } return(deband.ConvertToRgb()); }