PDA

View Full Version : COLOR_FormatYUV420Flexible transfer to RGB



Miss.shi
10-16-2017, 02:00 AM
I want to use GLSL to transfer YUV420 to RGB. But there have some problems when I start it. Android MediaCodecInfo.CodecCapabilities one constant is COLOR_FormatYUV420Flexible. This format corresponds to YUV_420_888, and can represent the COLOR_FormatYUV411Planar, COLOR_FormatYUV411PackedPlanar, COLOR_FormatYUV420Planar, COLOR_FormatYUV420PackedPlanar, COLOR_FormatYUV420SemiPlanar and COLOR_FormatYUV420PackedSemiPlanar formats. So different formats have different methods in YUV420 to RGB which writing in fragment shader.
I want to know the different methods in different formats YUV420 to RGB. Who can help me?

Dark Photon
10-16-2017, 06:31 AM
I want to use GLSL to transfer YUV420 to RGB. ... corresponds to YUV_420_888
... different formats have different methods in YUV420 to RGB which writing in fragment shader.

I want to know the different methods in different formats YUV420 to RGB. Who can help me?

It sounds like step 1 is to get to know the Android MediaCodec (http://android.xsoftlab.net/reference/android/media/MediaCodec.html) better (more links: LINK (http://bigflake.com/mediacodec/), LINK (https://stackoverflow.com/questions/tagged/mediacodec?sort=votes&pageSize=50), LINK (https://stackoverflow.com/questions/17105386/using-opengl-es-shader-to-convert-yuv-to-rgb)), so that you know which texel encodings and orderings you minimally need to support.

From this (http://android.xsoftlab.net/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_Format YUV420Flexible), it sounds like all of those other formats you mentioned are deprecated, so you might not even need to support anything but COLOR_FormatYUV420Flexible:



public static final int COLOR_FormatYUV420Flexible
Added in API level 21
(http://android.xsoftlab.net/guide/topics/manifest/uses-sdk-element.html#ApiLevels)
Flexible 12 bits per pixel, subsampled YUV color format with 8-bit chroma and luma components.

Chroma planes are subsampled by 2 both horizontally and vertically. Use this format with Image (http://android.xsoftlab.net/reference/android/media/Image.html). This format corresponds to YUV_420_888 (http://android.xsoftlab.net/reference/android/graphics/ImageFormat.html#YUV_420_888), and can represent the [deprecated formats] COLOR_FormatYUV411Planar (http://android.xsoftlab.net/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_Format YUV411Planar), COLOR_FormatYUV411PackedPlanar (http://android.xsoftlab.net/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_Format YUV411PackedPlanar), COLOR_FormatYUV420Planar (http://android.xsoftlab.net/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_Format YUV420Planar), COLOR_FormatYUV420PackedPlanar (http://android.xsoftlab.net/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_Format YUV420PackedPlanar), COLOR_FormatYUV420SemiPlanar (http://android.xsoftlab.net/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_Format YUV420SemiPlanar) and COLOR_FormatYUV420PackedSemiPlanar (http://android.xsoftlab.net/reference/android/media/MediaCodecInfo.CodecCapabilities.html#COLOR_Format YUV420PackedSemiPlanar)

Once you determine that, then the GLSL shader logic you need to convert to RGB should be pretty clear, since you'll know exactly how the memory is laid out. The GLSL source code might even be contained in one of the links I posted above.

By the way, if you don't get the answer you're looking for here, you might try posting on an Android and/or OpenGL ES (https://forums.khronos.org/forumdisplay.php/70-OpenGL-ES) forum. You're more likely to catch the eyes of devs familiar with MediaCodec there.