Camera2 YUV_420_888 wrong data in Galaxy A23


I’ve noticed that when requesting Camera2 ImageFormat.YUV_420_888 VGA data on the specified device - Galaxy A23 (SM-A236B) - the Y, U and V channels have unexpected sizes and row strides.

Requesting a similar image reader:

mImageReader = ImageReader.NewInstance(640, 480, ImageFormatType.Yuv420888, 5);


Y row stride = 1024 / Y size bytes = 491136
UV row stride = 1024 / UV pixel stride = 2 / UV size bytes =  245375

when it should be:

Y row stride = 640 / Y size bytes = 307200
UV row stride = 640 / UV pixel stride = 2 / UV size bytes =  153599

This was visible in all Android versions available for this device.

Could you please let me know if there is an issue with your Camera2 implementation on this device or if you are returning something that is not YUV_420_888.

Looking forward to your response

Hello, I think you should submit a support request here

In this case, you need to be sure that you correctly configure the image format available when prompted by the Camera2 API. If you match ImageFormat.YUV_420_888, then the corresponding Y, U and V, should have the appropriate dimensions and line steps. However, if you are sure to change the image scale, it is possible that the scaling problem with the Camera2 implementation is approaching an outcome. In this case, it is recommended to prefer the device manufacturer or the developer of the Android system infection for more information and a solution to the problem. You can also try using other image formats, such as ImageFormat. NV21 to make sure that the problem does not affect the YUV format.

@SachinKumar Although Camera1 returns Y “normally” i found the camera2 returns Y with padding hence the values (y Row stride > requested width). For example, in the first row, the values past index 640 on Y are filled with zeros. I’m pretty sure this is a manufacturer limitation so it would be nice to have this data somewhere so we know which devices can behave differently…

There is more issues with this device and Camera2/Vulkan… but i won’t even start on those to not mix issues into this one.