public void SetVideoFormat(OeipVideoType videoType, int width, int height) { //YUV类型数据 var yuvType = OeipHelper.getVideoYUV(videoType); YUV2RGBAParamet yuvParamet = new YUV2RGBAParamet(); yuvParamet.yuvType = yuvType; Pipe.UpdateParamet(Yuv2Rgba, yuvParamet); int inputWidth = width; int inputHeight = height; Pipe.SetEnableLayer(Yuv2Rgba, true); Pipe.SetEnableLayer(MapChannel, false); //Pipe.SetEnableLayer(ResizeIndex, false); OeipDataType dataType = OeipDataType.OEIP_CU8C1; if (yuvType == OeipYUVFMT.OEIP_YUVFMT_OTHER) { Pipe.SetEnableLayer(Yuv2Rgba, false); if (videoType == OeipVideoType.OEIP_VIDEO_BGRA32) { Pipe.SetEnableLayer(MapChannel, true); MapChannelParamet mapChannelParamet = new MapChannelParamet(); mapChannelParamet.red = 2; mapChannelParamet.green = 1; mapChannelParamet.blue = 0; mapChannelParamet.alpha = 3; Pipe.UpdateParamet(MapChannel, mapChannelParamet); } else if (videoType == OeipVideoType.OEIP_VIDEO_RGB24) { dataType = OeipDataType.OEIP_CU8C3; } } else if (yuvType == OeipYUVFMT.OEIP_YUVFMT_YUV420SP || yuvType == OeipYUVFMT.OEIP_YUVFMT_YUV420P || yuvType == OeipYUVFMT.OEIP_YUVFMT_YUY2P) { dataType = OeipDataType.OEIP_CU8C1; inputHeight = height * 3 / 2; if (yuvType == OeipYUVFMT.OEIP_YUVFMT_YUY2P) { inputHeight = height * 2; } } else if (yuvType == OeipYUVFMT.OEIP_YUVFMT_UYVYI || yuvType == OeipYUVFMT.OEIP_YUVFMT_YUY2I || yuvType == OeipYUVFMT.OEIP_YUVFMT_YVYUI) { dataType = OeipDataType.OEIP_CU8C4; inputWidth = width / 2; } Pipe.SetInput(InputIndex, inputWidth, inputHeight, dataType); }
private void ResetPipe() { int inputHeight = VideoFormat.height * 2; OeipDataType dataType = OeipDataType.OEIP_CU8C1; if (yuvfmt == OeipYUVFMT.OEIP_YUVFMT_YUV420P) { inputHeight = VideoFormat.height * 3 / 2; } YUV2RGBAParamet paramet = new YUV2RGBAParamet(); paramet.yuvType = yuvfmt; Pipe.UpdateParamet(Yuv2Rgba, paramet); Pipe.SetInput(InputIndex, VideoFormat.width, inputHeight, dataType); //重新申请复制当前视频桢数据空间 FreeData(); int size = VideoFormat.width * inputHeight; yuvData = Marshal.AllocHGlobal(size); OnLiveImageChange?.Invoke(videoFormat); }
public void SetInput(int layerIndex, int width, int height, OeipDataType dataType = OeipDataType.OEIP_CU8C1, int inputIndex = 0) { OeipHelper.setPipeInput(PipeId, layerIndex, width, height, (int)dataType, inputIndex); bSetInput = true; }