2

I receive the preview data in NV21 format by:

public void onPreviewFrame(byte[] data, Camera camera)

I want to convert data to I420 format by libyuv. It seems NV21ToI420 or ConvertToI420 in include/libyuv/convert.h is what i need.

// Convert NV21 to I420.
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);


// Convert camera sample to I420 with cropping, rotation and vertical flip.
LIBYUV_API
int ConvertToI420(const uint8* src_frame, size_t src_size,
              uint8* dst_y, int dst_stride_y,
              uint8* dst_u, int dst_stride_u,
              uint8* dst_v, int dst_stride_v,
              int crop_x, int crop_y,
              int src_width, int src_height,
              int dst_width, int dst_height,
              enum RotationMode rotation,
              uint32 format);

Are there some examples to do that?

mpromonet
  • 8,785
  • 40
  • 48
  • 80
Jerikc XIONG
  • 3,189
  • 5
  • 36
  • 62
  • Might be useful https://github.com/tonyconstantinides/LiveMultimedia/blob/master/app/src/main/java/com/constantinnovationsinc/livemultimedia/utilities/ColorSpaceManager.java – JiTHiN Oct 06 '15 at 07:01
  • @JiTHiN Thanks. But i need use the libyuv which more efficient. – Jerikc XIONG Oct 06 '15 at 07:06

1 Answers1

1

Finally, i found a demo:

https://github.com/zenith22/libyuvDemo.git

Hope it is helpful !

Update:

I have added a project:

https://github.com/jpxiong/NV21CameraPreviewToI420Demo.git

More details, please read the README.md

Jerikc XIONG
  • 3,189
  • 5
  • 36
  • 62