title: NV21 to I420 in android
body: <p><strong>EDIT :</strong> I came across this libyuv that does the NV21 to I420 conversion, but i don't really understand how to call it.</p>
  
  <pre><code>// 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) 
  </code></pre>
  
  <p>I am passing the NV21 byte[] obtained from camera callback to the jni layer and converting it to unsigned char* as below</p>
  
  <pre><code>int yuvBufLen = env-&gt;GetArrayLength(yuvNV21);
  unsigned char* yuvNV21Buf = new unsigned char[yuvBufLen];
  env-&gt;GetByteArrayRegion(yuvNV21, 0, yuvBufLen,reinterpret_cast&lt;jbyte*&gt;(yuvNV21Buf));
  </code></pre>
  
  <p>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 ??    </p>
  
  <p>const uint8* src_y,<br>
  int src_stride_y,<br>
  const uint8* src_vu,<br>
  int src_stride_vu,<br>
  uint8* dst_y,<br>
  int dst_stride_y,<br>
  uint8* dst_u,<br>
  int dst_stride_u,<br>
  uint8* dst_v,<br>
  int dst_stride_v</p>
  
  <p>I have checked this <a href="https://stackoverflow.com/a/16873980/3437573">obtain yuv420 in ios</a> which explains how to get all the required parameters to call libyuv::NV12ToI420.</p>
  
  <p>Can someone please explain me how to achieve this??</p>
  
  <p>I am capturing frame byte[] from camera through the preview callback below</p>
  
  <pre><code>@Override
          public void onPreviewFrame(byte[] frameData, Camera camera) {
  </code></pre>
  
  <p>The frameData am getting is in NV21 format and I am trying to convert NV21 to I420.</p>