Planar drawing YUV420

In my project, I use an OpenH264 codec that is said to output data in a format YUV 4:2:0 planar. After decoding, I get one array with elements width * height * 1.5, which when displayed looks like this:

http://o3d.googlecode.com/svn/trunk/samples_webgl/assets/shaving_cream.png

Why are there four areas below the main one (which contains Y - responsible for shades of gray), instead of two, as in my second picture? Does this mean that the format is different or I'm wrong, and my world just collapsed?

I thought resoult should look like this:

enter image description here

+4
source share
3

. , U V . , U , - . V.

, , U V. . , RGB:)

+5

, YUV:

YUV420 Planar

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)];

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

+6

thiagolr . , ,

Yuv layout

, 4 , .

+1

Source: https://habr.com/ru/post/1570302/


All Articles