Shenzhen Kai Mo Rui Electronic Technology Co. LTDShenzhen Kai Mo Rui Electronic Technology Co. LTD

News

Audio and video codec: YUV444, YUV422, YUV420 understanding in YUV sampling format

Source:Shenzhen Kai Mo Rui Electronic Technology Co. LTD2020-06-13

Explanation of various sampling formats of YUV

Usually we use RGB to represent a color. The data displayed by the LCD in the computer system is RGB to represent the color of each pixel.

In our lives, there are two types of black-and-white TV sets and color TV sets. Two different cameras cannot be used to store two kinds of image data when shooting program sources.

So in order to be compatible with the two TV sets, experts introduced the YUV format instead of RGB, where Y represents brightness, and U and V represent color difference. Black and white TV sets only use Y signals, while color TV sets can be converted from YUV to RGB and then display colors.

Usually the YUV format we use is the ITU-R standard, also called YCbCr.

YUV is converted from data in RGB format.

YY = 0.299 x R + 0.587 x G + 0.114 x B + 0 U Cb = -0.169 x R-0.331 x G + 0.499 x B + 128 V Cr = 0.499 x R-0.418 x G-0.0813 x B + 128 YY = 0.299 x R + 0.587 x G + 0.114 x B + 0 U Cb = -0.169 x R-0.331 x G + 0.499 x B + 128 V Cr = 0.499 x R-0.418 x G-0.0813 x B + 128

Copy code

YUV4:4:4

In fact, YUV data occupies 8 bits each, and each pixel is composed of YUV

Data of 4 adjacent pixels in the same row: Y0U0V0 Y1U1V1 Y2U2V2 Y3U3V3

When storing: Y0U0V0 Y1U1V1 Y2U2V2 Y3U3V3 //That is, the data of each pixel YUV will be stored. Why is it called 4:4:4, which means that the data in 4 pixels has 4 Y, 4 U, 4 V

YUV4:2:2

In fact, most of the two adjacent pixels should have little difference in data. Therefore, in order to facilitate storage of the node space, part of the data of each pixel is lost.

Expert research shows that we are more sensitive to brightness, but not very sensitive to color. Therefore, the luminance Y data of each pixel is absolutely unchanged, and the color difference data can be discarded.

Data of 4 adjacent pixels in the same row: Y0U0V0 Y1U1V1 Y2U2V2 Y3U3V3

When storing: Y0U0 Y1V1    Y2U2   Y3V3 // For every two adjacent pixels, one discards the V data and the other discards the U data. Why is it called 4:2:2, which means that there are 4 Y and 2 in the adjacent 4 pixels. U, 2 V. It is also called YUYV in the order of storage above.

But to restore to RGB data, YUV must be required. For example, the first pixel only has Y0U0, which cannot be restored. At this time, only the V1 data of the next pixel can be used.

YUV during restoration: [Y0U0V1] [Y1U0V1] [Y2U2V3] [Y3U2V3] // Such restoration will theoretically affect the quality of the image, but we can’t see it.

YUV4:2:0

Experts further study and show that the data of two adjacent pixels in each row and the two pixels in the same position in the next row have little difference, and data can be further lost.

Such as two rows of pixel data:

Y00U00V00 Y01U01V01 Y02U02V02 Y03U03V03 ....

Y88U88V88 Y89U89V89 Y90U90V90 Y91U91V91...

When storing: Y00U00    Y01      Y02U02   Y03 // The Y data of each pixel is reserved, and only one U data is reserved for two pixel data. This row does not retain V data (YUV: 420)

 Y88V88    Y89      Y90V90   Y91 // .... Two pixel data only retains one V data, this row does not retain U data (YUV: 402) When restoring, only the upper and lower rows of 4 pixels in the same position can be restored together:

Y00U00V88 Y01U00V88 Y02U02V90 Y03U02V90

Y88U00V88 Y89U00V88 Y90U02V90 Y91U02V90

Comparison of various sampling formats of YUV

Let's take an image with a size of 1280*720 as an example:

In an RGB image, each pixel has three primary colors of red, green, and blue, each of which occupies 8 bits, which is one byte, so one pixel also occupies 24 bits, which is three words Section.

A picture of 1280 * 720 size occupies 1280 * 720 * 3/1024/1024 = 2.63 MB storage space.

[Use YUV4:4:4 format sample size]

The YUV4:4:4 format means that the collection ratios of the three components of Y, U, and V are the same. Therefore, in the generated image, the information of the three components of each pixel is complete, all of which are 8 bits, which is one byte.

Then its sample size is

3 * 1280 * 720/1024/1024 = 2.63MB

Compared with the original RGB image, the size is the same.

[Use YUV4:2:2 format sample size]

The sampling feature of YUV4:2:2 format is that in each adjacent two pixels, one discards the U component and the other discards the V component. Then its sampling size is:

(8 + 8) * 1280 * 720/8/1024/1024 = 1.76MB

It can be seen that the YUV 4:2:2 sampled image saves one-third of the storage space than the RGB model image, and the bandwidth occupied during transmission will also be reduced.

[Use YUV4:2:0 format sample size]

The sampling feature of the YUV4:2:0 format is that all pixels retain the Y component, the pixels in the same row only retain the U component or the V component, and the two adjacent pixels in the same row retain only the same Y component or U component.

Then its sample size is:

(8 * 1280 * 720 + 8 * 1280 * 720/2/2 + 8 * 1280 * 720/2 / 2) / 8/1024/1024 = 1.32MB

You can see that YUV 4:2:0 sampled images save half of the storage space than RGB model images, so it is also a more mainstream sampling method.

Related News

Professional Engineer

24-hour online serviceSubmit requirements and quickly customize solutions for you

+8613798538021