Planar YUV420 data layout

本秂侑毒 提交于 2019-12-03 03:10:00

It is exactly the way you assume. You are just overlooking that there are half as many U and V pixels across the width of the image. So the even numbered lines of U data are on the left, the odd numbered ones on the right. Followed by the V data.

To get it arranged the way you want to look at it, the decoder would have to interleave the U and V data. It doesn't do that. Just don't start looking at the image until you converted to RGB :)

The accepted answer is totally correct, I'm just adding more information about the conversion to YUV values:

size.total = size.width * size.height;
y = yuv[position.y * size.width + position.x];
u = yuv[(position.y / 2) * (size.width / 2) + (position.x / 2) + size.total];
v = yuv[(position.y / 2) * (size.width / 2) + (position.x / 2) + size.total + (size.total / 4)];

Reference: https://en.wikipedia.org/wiki/YUV

The diagram from thiagolr is very accurate. An accurate diagram that looks more like yours would be

The reason yours looks like it has 4 pictures is as explained by Hans Passant.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!