'YUV buffer size not matching image size

I am currently using Android Camera2 API and decoding the frames through an ImageReader in a YUV_420_888 format. I managed to get everything working, all looks perfectly fine for both 320*240 and 640*480 sizes. But when I switch to 176*144, I get a weird result.

With this format and image size, I should have 38016 bytes in my buffer : 25344 in the Y plane and 6336 bytes in both the U and V planes. Instead, my buffer contains 39152 bytes. I get a correct size on the Y plane, but I get 6904 bytes on both the U and V planes, which results in green stripes across the image after an RGB conversion.

Any suggestion as to why this is happening ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source