Exemplo n.º 1
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                var sourceSize = input.Output.Size;

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

                var targetSize = Renderer.TargetSize;

                CreateWeights((Size)sourceSize, targetSize);

                int lobes  = TapCount.ToInt() / 2;
                var shader = CompileShader("EwaScaler.hlsl",
                                           macroDefinitions:
                                           string.Format("LOBES = {0}; AR = {1}",
                                                         lobes, AntiRingingEnabled ? 1 : 0))
                             .Configure(
                    transform: size => targetSize,
                    arguments: new[] { AntiRingingStrength },
                    linearSampling: true
                    );

                return(GetEwaFilter(shader, new[] { input }));
            }
            protected override ITextureFilter CreateFilter(ITextureFilter sourceFilter)
            {
                if (sourceFilter.Output.Size == Renderer.TargetSize)
                {
                    return(sourceFilter);
                }

                try
                {
                    m_DxvaHd = Renderer.CreateDxvaHd((Size)sourceFilter.Output.Size, TextureFormat.Unorm8,
                                                     Renderer.TargetSize, TextureFormat.Unorm8, Quality);
                }
                catch (DxvaHdException)
                {
                    // DXVA HD not available; fallback
                    Renderer.FallbackOccurred = true;
                    return(sourceFilter);
                }

                var input = YuvMode ? sourceFilter.ConvertToYuv() : sourceFilter;

                if (sourceFilter.Output.Format != TextureFormat.Unorm8)
                {
                    // Convert input to Unorm8 (and unforunately murdering quality at the same time)
                    var copy = CompileShader("Copy.hlsl").Configure(linearSampling: false, format: TextureFormat.Unorm8);
                    input = new ShaderFilter(copy, input);
                }

                var result = new DxvaHdResizeFilter(m_DxvaHd, input);

                return(YuvMode ? result.ConvertToRgb() : result);
            }
Exemplo n.º 3
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 = GetShader(Neurons1);
                var shaderPass2 = GetShader(Neurons2);
                var interleave  = new Shader(FromFile("Interleave.hlsl"))
                {
                    Transform = transform
                };

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

                var yuv         = input.ConvertToYuv();
                var composition = input.Decompose();

                var resultY = interleave.ApplyTo(composition.Luma, shaderPass1.ApplyTo(yuv));
                var luma    = interleave.ApplyTo(resultY, shaderPass2.ApplyTo(resultY));

                composition = luma.ComposeWith(composition.Chroma, chromaOffset: new Vector2(-0.25f, -0.25f));
                var result = ChromaScaler.ScaleChroma(composition);

                return(result.Convolve(null, offset: new Vector2(0.5f, 0.5f)));
            }
Exemplo n.º 4
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)));
            }
Exemplo n.º 5
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                Func <TextureSize, TextureSize> transform = s => new TextureSize(2 * s.Width, 2 * s.Height);

                float[] arguments  = { EdgeStrength, Sharpness };
                string  fastToggle = FastMethod ? "FAST_METHOD=1;" : "";

                var pass0 = new Shader(FromFile("super-xbr.hlsl", entryPoint: "main_fragment", compilerOptions: "Pass = 0;" + fastToggle))
                {
                    Transform = transform, Arguments = arguments
                };
                var pass1 = new Shader(FromFile("super-xbr.hlsl", entryPoint: "main_fragment", compilerOptions: "Pass = 1;" + fastToggle))
                {
                    Arguments = arguments
                };
                var pass2 = new Shader(FromFile("super-xbr.hlsl", entryPoint: "main_fragment", compilerOptions: "Pass = 2;" + fastToggle))
                {
                    Arguments = arguments
                };

                // Skip if downscaling
                if ((Renderer.TargetSize <= input.Size()).Any)
                {
                    return(input);
                }

                ITextureFilter xbr = input
                                     .Apply(pass0)
                                     .Apply(pass1);

                return(ThirdPass
                    ? xbr.Apply(pass2)
                    : xbr.Resize(xbr.Size(), offset: new Vector2(0.5f, 0.5f)));
            }
Exemplo n.º 6
0
            public ITextureFilter CreateChromaFilter(ITextureFilter lumaInput, ITextureFilter chromaInput, TextureSize targetSize, Vector2 chromaOffset)
            {
                var chromaSize = chromaInput.Output.Size;

                CreateWeights(chromaSize, targetSize);

                var offset = chromaOffset + new Vector2(0.5f, 0.5f);
                int lobes  = TapCount.ToInt() / 2;
                var shader = CompileShader("EwaScaler.hlsl",
                                           macroDefinitions:
                                           string.Format("LOBES = {0}; AR = {1}; CHROMA = 1;",
                                                         lobes, AntiRingingEnabled ? 1 : 0))
                             .Configure(
                    transform: size => targetSize,
                    arguments: new[] { AntiRingingStrength, offset.X, offset.Y },
                    linearSampling: true
                    );

                // Fall back to default when downscaling is needed
                if (targetSize.Width < chromaSize.Width || targetSize.Height < chromaSize.Height)
                {
                    return(null);
                }

                var resizedLuma = lumaInput.SetSize(targetSize, tagged: true);

                return(GetEwaFilter(shader, new[] { resizedLuma, chromaInput }).ConvertToRgb());
            }
Exemplo n.º 7
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                var sourceSize = input.Size();

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

                var targetSize = Renderer.TargetSize;

                CreateWeights((Size)sourceSize, targetSize);

                int lobes  = TapCount.ToInt() / 2;
                var shader = new Shader(FromFile("EwaScaler.hlsl",
                                                 compilerOptions:
                                                 string.Format("LOBES = {0}; AR = {1}",
                                                               lobes, AntiRingingEnabled ? 1 : 0)))
                {
                    Transform      = size => targetSize,
                    Arguments      = new[] { AntiRingingStrength },
                    LinearSampling = true
                };

                return(GetEwaFilter(shader, new[] { input }));
            }
            private void DownscaleAndCalcVar(ITextureFilter input, TextureSize targetSize, out ITextureFilter mean, out ITextureFilter var)
            {
                var HDownscaler = new Shader(FromFile(SoftDownscaling ? "SoftDownscaler.hlsl" : "./Scalers/Downscaler.hlsl", compilerOptions: "axis = 0;"))
                {
                    Transform = s => new TextureSize(targetSize.Width, s.Height), Format = input.Output.Format
                };
                var VDownscaler = new Shader(FromFile(SoftDownscaling ? "SoftDownscaler.hlsl" : "./Scalers/Downscaler.hlsl", compilerOptions: "axis = 1;"))
                {
                    Transform = s => new TextureSize(s.Width, targetSize.Height), Format = input.Output.Format
                };
                var HVar = new Shader(FromFile("DownscaledVarI.hlsl", compilerOptions: "axis = 0;"))
                {
                    Transform = s => new TextureSize(targetSize.Width, s.Height), Format = input.Output.Format
                };
                var VVar = new Shader(FromFile("DownscaledVarII.hlsl", compilerOptions: "axis = 1;"))
                {
                    Transform = s => new TextureSize(s.Width, targetSize.Height), Format = input.Output.Format
                };

                var hMean = HDownscaler.ApplyTo(input);

                mean = VDownscaler.ApplyTo(hMean);

                var hVariance = HVar.ApplyTo(input, hMean);

                var = VVar.ApplyTo(hVariance, hMean, mean);
            }
Exemplo n.º 9
0
 public RgbFilter(ITextureFilter inputFilter, YuvColorimetric?colorimetric = null, bool?limitedRange = null, bool?limitChroma = null)
     : base(inputFilter)
 {
     Colorimetric       = colorimetric ?? Renderer.Colorimetric;
     OutputLimitedRange = limitedRange ?? Renderer.OutputLimitedRange;
     OutputLimitChroma  = limitChroma ?? Renderer.LimitChroma;
 }
Exemplo n.º 10
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                Func <TextureSize, TextureSize> transformWidth  = s => new TextureSize(2 * s.Width, s.Height);
                Func <TextureSize, TextureSize> transformHeight = s => new TextureSize(s.Width, 2 * s.Height);

                var nedi1Shader = new Shader(FromFile("NEDI-I.hlsl"))
                {
                    Arguments = LumaConstants
                };
                var nedi2Shader = new Shader(FromFile("NEDI-II.hlsl"))
                {
                    Arguments = LumaConstants
                };
                var nediHInterleaveShader = new Shader(FromFile("NEDI-HInterleave.hlsl"))
                {
                    Transform = transformWidth
                };
                var nediVInterleaveShader = new Shader(FromFile("NEDI-VInterleave.hlsl"))
                {
                    Transform = transformHeight
                };

                if (!UseNedi(input))
                {
                    return(input);
                }

                var nedi1 = nedi1Shader.ApplyTo(input);
                var nediH = nediHInterleaveShader.ApplyTo(input, nedi1);
                var nedi2 = nedi2Shader.ApplyTo(nediH);
                var nediV = nediVInterleaveShader.ApplyTo(nediH, nedi2);

                return(nediV.Convolve(ForceCentered ? Renderer.LumaUpscaler : null, offset: new Vector2(0.5f, 0.5f)));
            }
Exemplo n.º 11
0
        public ChromaScalerTag(ITextureFilter chromaFilter, string label)
            : base(label)
        {
            m_ChromaFilter = chromaFilter;

            AddInput(m_ChromaFilter);
        }
Exemplo n.º 12
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                Func <TextureSize, TextureSize> transform = s => new TextureSize(2 * s.Width, 2 * s.Height);

                float[] arguments  = { EdgeStrength, Sharpness };
                string  fastToggle = FastMethod ? "FAST_METHOD=1;" : "";

                var pass0 = CompileShader("super-xbr.hlsl", entryPoint: "main_fragment", macroDefinitions: "Pass = 0;" + fastToggle).Configure(transform: transform, arguments: arguments);
                var pass1 = CompileShader("super-xbr.hlsl", entryPoint: "main_fragment", macroDefinitions: "Pass = 1;" + fastToggle).Configure(arguments: arguments);
                var pass2 = CompileShader("super-xbr.hlsl", entryPoint: "main_fragment", macroDefinitions: "Pass = 2;" + fastToggle).Configure(arguments: arguments);

                // Skip if downscaling
                if (Renderer.TargetSize.Width <= input.Output.Size.Width &&
                    Renderer.TargetSize.Height <= input.Output.Size.Height)
                {
                    return(input);
                }

                ITextureFilter xbr = input
                                     .Apply(pass0)
                                     .Apply(pass1);

                return(ThirdPass
                    ? (ITextureFilter)xbr.Apply(pass2)
                    : xbr.Resize(xbr.Output.Size, offset: new Vector2(0.5f, 0.5f)));
            }
Exemplo n.º 13
0
            public ITextureFilter CreateChromaFilter(ITextureFilter lumaInput, ITextureFilter chromaInput, TextureSize targetSize, Vector2 chromaOffset)
            {
                float[] yuvConsts  = Renderer.Colorimetric.GetYuvConsts();
                var     chromaSize = chromaInput.Output.Size;
                var     lumaSize   = lumaInput.Output.Size;

                Vector2 adjointOffset = -chromaOffset * lumaSize / chromaSize;

                var crossBilateral = CompileShader("CrossBilateral.hlsl")
                                     .Configure(
                    arguments: new[] { chromaOffset.X, chromaOffset.Y, yuvConsts[0], yuvConsts[1] },
                    perTextureLinearSampling: new[] { false, false }
                    );

                // Fall back to default when downscaling is needed
                if (targetSize.Width < chromaSize.Width || targetSize.Height < chromaSize.Height)
                {
                    return(null);
                }

                var resizedLuma = lumaInput.SetSize(targetSize, tagged: true);
                var lowresYUV   = DownscaleLuma(lumaInput, chromaInput, chromaSize, adjointOffset);

                return(crossBilateral.ApplyTo(resizedLuma, lowresYUV).ConvertToRgb());
            }
Exemplo n.º 14
0
 public NNedi3HKernelFilter(IShaderFilterSettings <IKernel> settings, IDisposable buffer, int neuronCount, TextureSize textureSize, int[] localWorkSizes,
                            ITextureFilter <IBaseTexture> inputFilter)
     : base(settings, GlobalWorkSizesHelper.Get(textureSize.Height, textureSize.Width, localWorkSizes), localWorkSizes, inputFilter)
 {
     m_Buffer      = buffer;
     m_NeuronCount = neuronCount;
     m_TextureSize = textureSize;
 }
            private void ConvolveAndCalcR(ITextureFilter input, ITextureFilter sh, out ITextureFilter mean, out ITextureFilter r)
            {
                var Convolver = CompileShader("SinglePassConvolver.hlsl").Configure(format: input.Output.Format);
                var CalcR     = CompileShader("CalcR.hlsl").Configure(format: TextureFormat.Float16);

                mean = input.Apply(Convolver);
                r    = CalcR.ApplyTo(input, mean, sh);
            }
Exemplo n.º 16
0
 protected override ITextureFilter CreateFilter(ITextureFilter input)
 {
     return(ShaderFileNames.Aggregate(input,
                                      (current, filename) =>
                                      CompileShader(filename)
                                      .Configure(format: GetTextureFormat())
                                      .ApplyTo(current)));
 }
Exemplo n.º 17
0
            protected override ITextureFilter CreateFilter(ITextureFilter sourceFilter)
            {
                CreateTextures();

                var shader = CompileShader("CustomTextures.hlsl");

                return(shader.ApplyTo(sourceFilter, m_Texture1.ToFilter(), m_Texture2.ToFilter()));
            }
Exemplo n.º 18
0
            protected override ITextureFilter CreateFilter(ITextureFilter sourceFilter)
            {
                Create3DTexture();

                var shader = CompileShader("Lut3D.hlsl").Configure(linearSampling: true);

                return(shader.ApplyTo(sourceFilter, m_Texture3D.ToFilter()));
            }
            public ITextureFilter CreateChromaFilter(ITextureFilter lumaInput, ITextureFilter chromaInput, TextureSize targetSize, Vector2 chromaOffset)
            {
                DisposeHelper.Dispose(ref m_Buffer1);
                DisposeHelper.Dispose(ref m_Buffer2);

                if (!Renderer.IsOpenClAvail || Renderer.RenderQuality.PerformanceMode())
                {
                    Renderer.FallbackOccurred = true; // Warn user via player stats OSD
                    return(null);                     // OpenCL is not available; fallback
                }

                var lumaSize   = lumaInput.Output.Size;
                var chromaSize = chromaInput.Output.Size;

                if (lumaSize.Width != 2 * chromaSize.Width || lumaSize.Height != 2 * chromaSize.Height)
                {
                    return(null); // Chroma shouldn't be doubled; fallback
                }
                Func <TextureSize, TextureSize> transformWidth  = s => new TextureSize(2 * s.Width, s.Height);
                Func <TextureSize, TextureSize> transformHeight = s => new TextureSize(s.Width, 2 * s.Height);

                var kernelU  = CompileKernel(true);
                var kernelV  = CompileKernel(false);
                var shaderUh = kernelU.Configure(transform: transformWidth);
                var shaderUv = kernelU.Configure(transform: transformHeight);
                var shaderVh = kernelV.Configure(transform: transformWidth);
                var shaderVv = kernelV.Configure(transform: transformHeight);

                var neuronCount1 = s_NeuronCount[(int)Neurons1];
                var neuronCount2 = s_NeuronCount[(int)Neurons2];
                var weights1     = s_Weights[(int)Neurons1];

                m_Buffer1 = Renderer.CreateClBuffer(weights1);
                var differentWeights = neuronCount1 != neuronCount2;

                if (differentWeights)
                {
                    var weights2 = s_Weights[(int)Neurons2];
                    m_Buffer2 = Renderer.CreateClBuffer(weights2);
                }

                var localWorkSizes = new[] { 8, 8 };
                var nnedi3Uh       = new NNedi3HKernelFilter(shaderUh, m_Buffer1, neuronCount1,
                                                             new TextureSize(chromaSize.Width, chromaSize.Height),
                                                             localWorkSizes, chromaInput);
                var nnedi3Uv = new NNedi3VKernelFilter(shaderUv, m_Buffer2, neuronCount2, differentWeights,
                                                       new TextureSize(nnedi3Uh.Output.Size.Width, nnedi3Uh.Output.Size.Height),
                                                       localWorkSizes, nnedi3Uh);

                var nnedi3Vh = new NNedi3HKernelFilter(shaderVh, m_Buffer1, neuronCount1,
                                                       new TextureSize(chromaSize.Width, chromaSize.Height),
                                                       localWorkSizes, chromaInput);
                var nnedi3Vv = new NNedi3VKernelFilter(shaderVv, m_Buffer2, neuronCount2, differentWeights,
                                                       new TextureSize(nnedi3Vh.Output.Size.Width, nnedi3Vh.Output.Size.Height),
                                                       localWorkSizes, nnedi3Vh);

                return(lumaInput.MergeWith(nnedi3Uv, nnedi3Vv).ConvertToRgb());
            }
Exemplo n.º 20
0
        public ITextureFilter CreateChromaFilter(ITextureFilter lumaInput, ITextureFilter chromaInput, TextureSize targetSize, Vector2 chromaOffset)
        {
            var fullSizeChroma = new ResizeFilter(chromaInput, targetSize, TextureChannels.ChromaOnly,
                                                  chromaOffset, Renderer.ChromaUpscaler, Renderer.ChromaDownscaler);

            return(new MergeFilter(lumaInput.SetSize(targetSize, tagged: true), fullSizeChroma)
                   .ConvertToRgb()
                   .Tagged(new ChromaScalerTag(chromaInput, fullSizeChroma.Status().PrependToStatus("Chroma: "))));
        }
Exemplo n.º 21
0
        public ITextureFilter CreateChromaFilter(ITextureFilter lumaInput, ITextureFilter chromaInput, TextureSize targetSize, Vector2 chromaOffset)
        {
            if (lumaInput is YSourceFilter && chromaInput is ChromaSourceFilter && chromaOffset == Renderer.ChromaOffset)
            {
                return(m_SourceFilter.SetSize(targetSize, tagged: true));
            }

            return(null);
        }
Exemplo n.º 22
0
        public static ICompositionFilter ComposeWith(this ITextureFilter luma, ITextureFilter chroma, ICompositionFilter copyParametersFrom = null, TextureSize?targetSize = null, Vector2?chromaOffset = null)
        {
            if (copyParametersFrom != null)
            {
                return(new CompositionFilter(luma, chroma, targetSize ?? copyParametersFrom.TargetSize, chromaOffset ?? copyParametersFrom.ChromaOffset));
            }

            return(new CompositionFilter(luma, chroma, targetSize, chromaOffset));
        }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes the background download of the texture in textureUrl
 /// It will also apply the filter after the download is complete.
 /// By using PTaskScheduler, all textures are downloaded and filtered in parallel
 /// </summary>
 /// <param name="textureFilter">Texture filter.</param>
 /// <param name="textureUrl">Texture URL.</param>
 public TextureDownloader(ITextureFilter textureFilter, string textureUrl)
 {
     mTextureFilter   = textureFilter;
     mTextureData     = null;
     mFilteredTexture = null;
     mTextureColors   = null;
     mFiltered        = false;
     StartTextureProcessing(textureUrl);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes the background download of the texture in textureUrl
 /// It will also apply the filter after the download is complete.
 /// By using PTaskScheduler, all textures are downloaded and filtered in parallel
 /// </summary>
 /// <param name="textureFilter">Texture filter.</param>
 /// <param name="textureUrl">Texture URL.</param>
 public TextureDownloader(ITextureFilter textureFilter, string textureUrl)
 {
     mTextureFilter = textureFilter;
     mTextureData = null;
     mFilteredTexture = null;
     mTextureColors = null;
     mFiltered = false;
     StartTextureProcessing(textureUrl);
 }
Exemplo n.º 25
0
        public static ITextureFilter SetSize(this ITextureFilter <ITexture2D> filter, TextureSize size, bool tagged = false)
        {
            var resizeable = (filter as IResizeableFilter) ?? new ResizeFilter(filter);

            if (tagged)
            {
                resizeable.EnableTag();
            }
            return(resizeable.SetSize(size));
        }
Exemplo n.º 26
0
            public override ITextureFilter Process(ITextureFilter input)
            {
                if (string.IsNullOrWhiteSpace(Condition) ||
                    !RenderScriptEngine.Eval(input, GetScript(), GetType().Name))
                {
                    return(input);
                }

                return(base.Process(input));
            }
Exemplo n.º 27
0
        public static IResizeableFilter Resize(this ITextureFilter <ITexture2D> inputFilter, TextureSize outputSize, TextureChannels?channels = null, Vector2?offset = null, IScaler upscaler = null, IScaler downscaler = null, IScaler convolver = null, TextureFormat?outputFormat = null, bool tagged = false)
        {
            var result = new ResizeFilter(inputFilter, outputSize, channels ?? TextureChannels.All, offset ?? Vector2.Zero, upscaler, downscaler, convolver, outputFormat);

            if (tagged)
            {
                result.EnableTag();
            }
            return(result);
        }
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                var composition = input as ICompositionFilter;

                if (composition == null)
                {
                    return(input);
                }

                return(ScaleChroma(composition));
            }
Exemplo n.º 29
0
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                if (Renderer.InputFormat.IsRgb())
                {
                    return(input);
                }

                int bits = Renderer.InputFormat.GetBitDepth();

                if (bits > MaxBitDepth)
                {
                    return(input);
                }

                float[] consts =
                {
                    (1 << bits) - 1,
                    Power
                };

                var Deband = new Shader(FromFile("Deband.hlsl", compilerOptions: PreserveDetail ? "PRESERVE_DETAIL=1" : ""))
                {
                    Arguments = consts,
                    PerTextureLinearSampling = new[] { true, false }
                };

                ITextureFilter yuv       = input.ConvertToYuv();
                var            inputsize = yuv.Size();

                var    deband = yuv;
                double factor = 2.0;// 0.5 * Math.Sqrt(5) + 0.5;

                int maxWidth = Math.Min(Math.Min(inputsize.Width, inputsize.Height) / 3, 256);
                int max      = (int)Math.Floor(Math.Log(maxWidth, factor));

                for (int i = max; i >= 0; i--)
                {
                    double scale = Math.Pow(factor, i);
                    var    size  = new TextureSize((int)Math.Round(inputsize.Width / scale), (int)Math.Round(inputsize.Height / scale));
                    if (size.Width == 0 || size.Height == 0)
                    {
                        continue;
                    }
                    if (i == 0)
                    {
                        size = inputsize;
                    }

                    Deband.Transform = s => size;
                    deband           = Deband.ApplyTo(yuv, deband);
                }

                return(deband.ConvertToRgb());
            }
Exemplo n.º 30
0
        public static ITextureFilter ConvertToYuv(this ITextureFilter filter)
        {
            var sourceFilter = filter as VideoSourceFilter;

            if (sourceFilter != null)
            {
                return(sourceFilter.GetYuv());
            }

            return(new YuvFilter(filter));
        }
            protected override ITextureFilter CreateFilter(ITextureFilter input)
            {
                var clip = RenderScriptEngine.Exec(input, BuildScript(ScriptFileName), ScriptFileName);

                if (clip == null)
                {
                    return(null);
                }

                return(clip.Filter);
            }