How to use OpenGL ES shader to convert rgbaToYuv and then render onto ImageReader's surface

231 Views Asked by At

I want to fill the ImageReader by openGl.

and my shader can convert rgbaToyuv.

So here is my code:

ImageReader.newInstance(vConfig.width, vConfig.height, ImageFormat.YUV_420_888, 2, /*1 << 17*/);
eglSurface= eglCreateWindowSurface(xxx, imageReader.getSurface, xxx);
glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureOfCameraFrame);
eglSwapBuffers(eglDisplay, mEGLSurface);

But i got below error:

The producer output buffer format 0x1(RGBA) doesn't match the ImageReader's configured buffer format 0x23(YUV_420_888)

from https://cs.android.com/android/platform/superproject/+/master:frameworks/base/media/jni/android_media_ImageReader.cpp;l=590

it says that imgReaderFmt != bufferFormat.

But what can i do to make it work with YUV_420_888 format.

1

There are 1 best solutions below

0
On

If you want the GPU to render YUV you'll need to use the EXT_YUV_target extension functionality to set up a YUV render pass.

https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_YUV_target.txt