Ejemplo n.º 1
0
        internal void Deinterlace(IVideoFrame frame, IRenderFrame destination, DeinterlaceModes mode)
        {
            try
            {
                using (var ll = this.GetDrawLock())
                {
                    //   Lock();
                    GL.BindFramebuffer(FramebufferTarget.Framebuffer, (destination as RenderFrame).framebuffer);

                    var err = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

                    GL.Viewport(0, 0, destination.Width, destination.Height);// new Rectangle(this.window.Location,this.window.ClientSize));

                    GL.ClearColor(1, 1, 0, 1);
                    GL.Clear(ClearBufferMask.ColorBufferBit /*| ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing?

                    GL.Disable(EnableCap.DepthTest);
                    GL.Disable(EnableCap.StencilTest);

                    GL.ActiveTexture(TextureUnit.Texture0);
                    GL.BindTexture(TextureTarget.Texture2D, (frame as IOpenGLFrame).Textures[0]);

                    shader pp;
                    switch (mode)
                    {
                    default:
                        throw new NotImplementedException();

                    case DeinterlaceModes.Blend:
                        pp = deinterlaceblendshader;
                        break;

                    case DeinterlaceModes.Split:
                        pp = deinterlacesplitshader;
                        break;
                    }
                    pp.Bind(vertices2);
                    var locvpheight = GL.GetUniformLocation(pp, "vpHeight");
                    GL.Uniform1(locvpheight, destination.Height);


                    GL.DrawArrays(PrimitiveType.Quads, 0, 4);

                    GL.DisableVertexAttribArray(0);
                    GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                    GL.ActiveTexture(TextureUnit.Texture0);
                    GL.BindTexture(TextureTarget.Texture2D, 0);
                    GL.UseProgram(0);

                    //  vertices3.Bind();
                    GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
                }
            }
            catch (Exception e)
            {
                //      Log.LogException(e);
            }
        }
Ejemplo n.º 2
0
        internal void Deinterlace(IVideoFrame frame, IRenderFrame destination, DeinterlaceModes mode)
        {
            if (this.device != null)
            {
                switch (mode)
                {
                default:
                    throw new NotImplementedException();

                case DeinterlaceModes.Blend:
                case DeinterlaceModes.Split:
                {
                    var state = this.StartRender(destination, rectangle.Zero);
                    try
                    {
                        /*         var dstrec = new System.Drawing.Rectangle(0, 0, destination.Width, destination.Height);
                         *       var effect = this.effect2;
                         *       var m = Matrix.Scaling(dstrec.Width, dstrec.Height, 1) * Matrix.Translation(dstrec.Left, dstrec.Top, 0);
                         *       var worldViewProj = m * this.CreateViewMatrix(destination.Width, destination.Height);
                         *       int n;
                         *       switch (mode)
                         *       {
                         *           case DeinterlaceModes.Blend:
                         *               {
                         *                   effect.SetValue("worldViewProj", worldViewProj);
                         *                   effect.SetTexture("texture0", (frame as IDirectXFrame).Textures[0]);
                         *                   effect.SetValue("vpHeight", frame.Height);
                         *                   n = 1;
                         *               }
                         *               break;
                         *           case DeinterlaceModes.Split:
                         *               {
                         *                   effect.SetValue("worldViewProj", worldViewProj);
                         *                   effect.SetTexture("texture0", (frame as IDirectXFrame).Textures[0]);
                         *                   effect.SetValue("vpHeight", frame.Height);
                         *                   n = 0;
                         *               }
                         *               break;
                         *           default:
                         *               throw new NotImplementedException();
                         *       }
                         *       this.Paint(
                         *           new System.Drawing.Rectangle(0, 0, destination.Width, destination.Height),
                         *           effect, n);*/
                    }
                    finally
                    {
                        this.EndRender(state);
                    }
                }
                break;
                }
            }
        }
Ejemplo n.º 3
0
 public void Deinterlace(IRenderFrame deinterlace, DeinterlaceModes mode)
 {
     owner.Deinterlace(this, deinterlace, mode);
 }
Ejemplo n.º 4
0
 public void Deinterlace(IRenderFrame destination, DeinterlaceModes mode)
 {
     this.owner.Deinterlace(this, destination, mode);
 }