How can I replicate the functionality of CVPixelBufferGetBaseAddressOfPlane in other languages as java, c# or c++?
How can I replicate the functionality of CVPixelBufferGetBaseAddressOfPlane in other languages as java, c#
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The YUV420SP format consists of two planes. The first plane contains the luminance information (Y values) and the second one contains the chrominance values (U and V values). Futhermore, there is a Y value for each pixel but just a U and a V value for each 2 by 2 pixel block. Finally, the U and V values are interleaved in the second plane.
So your byte array is most likely organized like this (each byte contains either a Y, U or V value):
Let’s assume the image is 400 by 300 pixels. Then you have 120,000 Y values followed by 30,000 U/V pairs.
Since you’re using Java and Java doesn’t have pointers that can point into the middle of an array, you will need to use array indices instead of addresses. So a more or less equivalent implementation of
CVPixelBufferGetBaseAddressOfPlanecould look like this:Most likely, your image data doesn’t contain any information about the size of the image. So you’ll have to get that information from somewhere else and provide it to the method. On the other hand, you don’t need to provide the byte array to the method. It’s not required to compute the offset of any of the planes.