crow-misia / libyuv-android

LibYUV for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YUV420p conversion incorrect color

TinTran64 opened this issue · comments

I've been trying to convert a YUV420 buffer to ARGB but the output image is not in correct color. I've also tried NV21 and NV12 but still no luck :(

In the sample files has the yuv file that I used ffmpeg extract and an jpeg file of how the frame should be displaying

val w = 956
val h = 1080
val yuvBuffer = I420Buffer.allocate(w, h)
yuvBuffer.asBuffer().put(byteArray)
val argbBuffer = ArgbBuffer.allocate(w, h)
yuvBuffer.convertTo(rgbaBuffer)
val bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
bitmap.copyPixelsFromBuffer(argbBuffer.asBuffer())

sample.zip

Use AbgrBuffer instead of ArgbBuffer

The order of the data in ARGB_8888 is RGBA in memory.

I've tried both ArgbBuffer and RgbaBuffer

I420Buffer -> ArgbBuffer

I420Buffer -> RgbaBuffer

Expected:

please use AbgrBuffer

Oh! Sorry I thought you mean RGBA..... It's working now. Thank you so much!