Introducing
YUV444: when sampling, Y, U, V are sampled at the same ratio, and each pixel occupies the same component
YUV422: when sampling, Y and UV components are sampled at a ratio of 2: 1, and every two Y components are common An array of UV components.
YUV420: When sampling, the Y and UV components are sampled at a ratio of 4: 1, and every four Ys share a set of UV components.
YU12: YUV420p format. It is also called I420 on the Android platform, arrange Y first, then arrange U and V.
YV12: YUV420p format. Arrange Y first, followed by V and U.
NV12: YUV420sp format. Generally applicable to the iOS platform, arrange Y first, and store UV alternately.
NV21: YUV420sp format. The preview data collected by the Android platform camera is generally NV21, the Y is arranged first, and the VU is stored alternately.
Arrangement (take 6*4 image as an example)
YUV444
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
U U U U U U
U U U U U U
U U U U U U
U U U U U U
V V V V V V
V V V V V V
V V V V V V
V V V V V V
YUV422
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
U U U U U U
U U U U U U
V V V V V V
V V V V V V
YU12
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
U U U U U U
V V V V V V
YV12
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
V V V V V V
U U U U U U
NV12
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
U V U V U V
U V U V U V
NV21
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
V U V U V U
V U V U V U
Storage space (take 6*4 image as an example)
YUV444: Y, U, V each occupy 8 bits, total occupancy = (6 * 4 + 6 * 4 * 2) = 72 bytes
YUV422: Y occupies 8 bits, UV each occupies 4 bits, total occupancy = (6 * 4 + 6 * 4 / 2 * 2) = 48 bytes
YUV420: Y occupies 8 bits, UV each occupies 2 bits, total occupancy = (6 * 4 + 6 * 4 / 4 * 2) = 36 bytes I420
: equivalent to YUV420, 36 bytes
YV12: Equivalent to YUV420, 36 bytes
NV12: Equivalent to YUV420, 36 bytes
NV21: Equivalent to YUV420, 36 bytes
storage format
planar 平面格式:指先连续存储所有像素点的 Y 分量,然后存储 U 分量,最后是 V 分量。
(以YU12格式6*4图像为例) Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
Y Y Y Y Y Y
U U U U U U
V V V V V V
packed 打包模式:指每个像素点的 Y、U、V 分量是连续交替存储的。
(以YU12格式6*4图像为例) Y Y U Y Y V
Y Y U Y Y V
Y Y U Y Y V
Y Y U Y Y V
Y Y U Y Y V
Y Y U Y Y V