Ejemplo n.º 1
0
        private void PresentYUV(MediaFrame frame, bool dispose = true)
        {
            try
            {
                srvY = new ShaderResourceView(device, frame.textureY, srvDescYUV);
                srvU = new ShaderResourceView(device, frame.textureU, srvDescYUV);
                srvV = new ShaderResourceView(device, frame.textureV, srvDescYUV);

                context.PixelShader.SetShaderResources(0, srvY, srvU, srvV);
                context.PixelShader.Set(pixelShaderYUV);
            } catch (Exception) {
            } finally
            {
                if (dispose)
                {
                    Utilities.Dispose(ref frame.textureY);
                    Utilities.Dispose(ref frame.textureU);
                    Utilities.Dispose(ref frame.textureV);
                }

                Utilities.Dispose(ref srvY);
                Utilities.Dispose(ref srvU);
                Utilities.Dispose(ref srvV);
            }
        }
Ejemplo n.º 2
0
        private void PresentNV12P010(MediaFrame frame, bool dispose = true)
        {
            // TODO: Possible process it directly after decoding (back to FFmpeg) to avoid Flush?
            try
            {
                Utilities.Dispose(ref vpiv);
                videoDevice1.CreateVideoProcessorInputView(frame.textureHW, vpe, vpivd, out vpiv);

                VideoProcessorStream vps = new VideoProcessorStream()
                {
                    PInputSurface = vpiv,
                    Enable        = new RawBool(true)
                };
                vpsa[0] = vps;
                videoContext1.VideoProcessorBlt(videoProcessor, vpov, 0, 1, vpsa);

                context.PixelShader.SetShaderResource(0, srvRGB);
                context.PixelShader.Set(pixelShader);
            } catch (Exception) {
            } finally { if (dispose)
                        {
                            Utilities.Dispose(ref frame.textureHW);
                        }
            }
        }
Ejemplo n.º 3
0
        public void PresentFrame(MediaFrame frame = null)
        {
            // Design Mode Only?
            if (device == null)
            {
                return;
            }

            // Should work better in case of frame delay (to avoid more delay on screamer)
            if (Monitor.TryEnter(device, 4))
            {
                try
                {
                    if (frame != null)
                    {
                        // NV12 | P010
                        if (frame.textureHW != null)
                        {
                            PresentNV12P010(frame);
                        }

                        // YUV420P
                        else if (frame.textureY != null)
                        {
                            PresentYUV(frame);
                        }

                        // RGB
                        else if (frame.textureRGB != null)
                        {
                            PresentRGB(frame);
                        }
                    }

                    context.OutputMerger.SetRenderTargets(rtv);
                    context.ClearRenderTargetView(rtv, clearColor);
                    context.Draw(6, 0);

                    rtv2d.BeginDraw();
                    try
                    {
                        PresentOSD();
                    } finally {
                        rtv2d.EndDraw();
                    }
                    swapChain.Present(vsync, PresentFlags.None);
                } finally { Monitor.Exit(device); }
            }
            else
            {
                Console.WriteLine("[RENDERER] Drop Frame - Lock timeout " + (frame != null ? Utils.TicksToTime(frame.timestamp) : "")); player.ClearVideoFrame(frame);
            }
        }
Ejemplo n.º 4
0
        private void PresentRGB(MediaFrame frame, bool dispose = true)
        {
            try
            {
                srvRGB = new ShaderResourceView(device, frame.textureRGB);
                context.PixelShader.SetShaderResources(0, srvRGB);
                context.PixelShader.Set(pixelShader);
            } catch (Exception) {
            } finally
            {
                if (dispose)
                {
                    Utilities.Dispose(ref frame.textureRGB);
                }

                Utilities.Dispose(ref srvRGB);
            }
        }