问题
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