How to convert ARGB8888 to 420Yp8_CbCr8 in Xamarin.iOS?

喜欢而已 提交于 2019-12-24 06:34:29

问题


I am recording video using AVFoundation and has a video output configured to provide frames with the pixelformat: CVPixelFormatType.CV32BGRA.

I have chosen this format since, it is easier to do cropping and other tranformation on this format than on a yuv420p frame. However the final format is needed to be CVPixelFormatType.CV420YpCbCr8BiPlanarVideoRange, hence I am now trying to use the following method from vImageConvert, but I fail to bind it properly.

I am trying to access the vImageConvert_ARGB8888To420Yp8_CbCr8 C function from Xamarin, but it is not supported or at least not binded.

I have tried the following:

[DllImport("/System/Library/Frameworks/Accelerate.framework/Frameworks/vImage.framework/vImage")]
extern static vImageError vImageConvert_ARGB8888To420Yp8_CbCr8(ref vImageBuffer src, ref vImageBuffer destYp, ref vImageBuffer destCbCr, vImage_ARGBToYpCbCr info, [MarshalAs(UnmanagedType.LPArray)]uint[] permuteMap, vImageFlags flags);

However I fail to find the proper type for the info parameter. Should it just be IntPtr? And if how do I resolve the proper type when I need to call this extern static method?

I was following this SO question: How to convert BGRA to RGBA in Xamarin.iOS? but now I am stucked on the type for the info parameter.

Thanks.

来源:https://stackoverflow.com/questions/54327771/how-to-convert-argb8888-to-420yp8-cbcr8-in-xamarin-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!