问题
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?
回答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
来源:https://stackoverflow.com/questions/32963581/how-to-convert-android-camera-preview-data-in-nv21-format-to-i420-by-libyuv