Exemple #1
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                if (!Renderer.IsDx11Avail)
                {
                    Renderer.FallbackOccurred = true; // Warn user via player stats OSD
                    return(input);                    // DX11 is not available; fallback
                }

                Func <TextureSize, TextureSize> transform = s => new TextureSize(2 * s.Height, s.Width);

                var shaderPass1 = LoadShader11(GetShaderFileName(Neurons1));
                var shaderPass2 = LoadShader11(GetShaderFileName(Neurons2));
                var interleave  = CompileShader("Interleave.hlsl").Configure(transform: transform);

                var sourceSize = input.Size();

                if ((Renderer.TargetSize <= sourceSize).Any)
                {
                    return(input);
                }

                var yuv = input.ConvertToYuv();

                m_Filter1 = NNedi3Helpers.CreateFilter(shaderPass1, yuv, Neurons1, Structured);
                var resultY = interleave.ApplyTo(yuv, m_Filter1);

                m_Filter2 = NNedi3Helpers.CreateFilter(shaderPass2, resultY, Neurons2, Structured);
                var luma = interleave.ApplyTo(resultY, m_Filter2);

                var result = ChromaScaler.ScaleChroma(
                    new CompositionFilter(luma, yuv, targetSize: luma.Size(), chromaOffset: new Vector2(-0.25f, -0.25f)));

                return(result.Convolve(null, offset: new Vector2(0.5f, 0.5f)));
            }
Exemple #2
0
            public override IFilter CreateFilter(IFilter input)
            {
                Cleanup();

                if (!Renderer.IsDx11Avail)
                {
                    Renderer.FallbackOccurred = true; // Warn user via player stats OSD
                    return(input);                    // DX11 is not available; fallback
                }

                Func <TextureSize, TextureSize> transform = s => new TextureSize(2 * s.Height, s.Width);

                var shaderPass1 = LoadShader11(GetShaderFileName(Neurons1));
                var shaderPass2 = LoadShader11(GetShaderFileName(Neurons2));
                var interleave  = CompileShader("Interleave.hlsl").Configure(transform: transform);
                var combine     = CompileShader("Combine.hlsl").Configure(transform: transform);

                var sourceSize = input.OutputSize;

                if (!IsUpscalingFrom(sourceSize))
                {
                    return(input);
                }

                var yuv = input.ConvertToYuv();

                var chroma = new ResizeFilter(yuv, new TextureSize(sourceSize.Width * 2, sourceSize.Height * 2),
                                              TextureChannels.ChromaOnly, new Vector2(-0.25f, -0.25f), Renderer.ChromaUpscaler, Renderer.ChromaDownscaler);

                m_Filter1 = NNedi3Helpers.CreateFilter(shaderPass1, yuv, Neurons1, Structured);
                var resultY = new ShaderFilter(interleave, yuv, m_Filter1);

                m_Filter2 = NNedi3Helpers.CreateFilter(shaderPass2, resultY, Neurons2, Structured);
                var result = new ShaderFilter(combine, resultY, m_Filter2, chroma);

                return(new ResizeFilter(result.ConvertToRgb(), result.OutputSize, new Vector2(0.5f, 0.5f),
                                        Renderer.LumaUpscaler, Renderer.LumaDownscaler));
            }