// Start is called before the first frame update void Awake() { pipe = OeipManager.Instance.CreatePipe <OeipPipe3D>(OeipGpgpuType.OEIP_CUDA); InputIndex = pipe.AddLayer("input", OeipLayerType.OEIP_INPUT_LAYER); int mapIndex = pipe.AddLayer("map", OeipLayerType.OEIP_MAPCHANNEL_LAYER); int r2y = pipe.AddLayer("rgba2yuv", OeipLayerType.OEIP_RGBA2YUV_LAYER); OutputIndex = pipe.AddLayer("output", OeipLayerType.OEIP_OUTPUT_LAYER); InputParamet input = new InputParamet(); input.bCpu = 0; input.bGpu = 1; pipe.UpdateParamet(InputIndex, input); if (pipe.GpgpuType == OeipGpgpuType.OEIP_CUDA) { MapChannelParamet mp = new MapChannelParamet(); mp.blue = 0; mp.green = 1; mp.red = 2; mp.alpha = 3; pipe.UpdateParamet(mapIndex, mp); } RGBA2YUVParamet rp = new RGBA2YUVParamet(); rp.yuvType = yUVFMT; pipe.UpdateParamet(r2y, rp); OutputParamet op = new OutputParamet(); op.bCpu = 1; op.bGpu = 0; pipe.UpdateParamet(OutputIndex, op); }
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); }