EDIT : I came across this libyuv that does the NV21 to I420 conversion, but i don't really understand how to call it.
// Convert NV21 to I420. Same as NV12 but u and v pointers swapped.
LIBYUV_API
int NV21ToI420(const uint8* src_y, int src_stride_y,
const uint8* src_vu, int src_stride_vu,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height)
I am passing the NV21 byte[] obtained from camera callback to the jni layer and converting it to unsigned char* as below
int yuvBufLen = env->GetArrayLength(yuvNV21);
unsigned char* yuvNV21Buf = new unsigned char[yuvBufLen];
env->GetByteArrayRegion(yuvNV21, 0, yuvBufLen,reinterpret_cast<jbyte*>(yuvNV21Buf));
Now it is not clear to me how do i get the different parameters required to call the libyuv function NV21ToI420. What does each of the following parameters represent and how to obtain them from the unsigned char* yuvNV21Buf I have ??
const uint8* src_y,
int src_stride_y,
const uint8* src_vu,
int src_stride_vu,
uint8* dst_y,
int dst_stride_y,
uint8* dst_u,
int dst_stride_u,
uint8* dst_v,
int dst_stride_v
I have checked this obtain yuv420 in ios which explains how to get all the required parameters to call libyuv::NV12ToI420.
Can someone please explain me how to achieve this??
I am capturing frame byte[] from camera through the preview callback below
@Override
public void onPreviewFrame(byte[] frameData, Camera camera) {
The frameData am getting is in NV21 format and I am trying to convert NV21 to I420.