当前位置:网站首页>Some summary about YUV format

Some summary about YUV format

2022-06-10 18:46:00 dongfangxingyu1

One 、YUV and YCbCr

1、 Definition

YUV, It's a color coding method , It is often used in various video processing components .Y Indicates brightness (Luminance or Luma), That's the gray scale value ,U and V It's color (Chrominance or Chroma), It is used to describe image color and saturation , Used to specify the color of pixels .

YCbCr, there Y and YUV Of Y identical , and Cb and Cr It is the concentration offset component of blue and red , It is also used to express color .

2、 Difference and connection

In essence, there is no difference between the two ,YCbCr  Is in the world digital organization video standard development process as ITU - R BT.601 Part of the proposal , It's actually YUV A scaled and offset reproduction .

YUV Mainly used in color TV , Used for analog signal representation .YCbCr It is used in digital video 、 Image compression and transmission , for example H264、HEVC、JPEG、MPEG All in this format . What people say YUV Most of it means YCbCr.

Two 、 Different sampling Format

Write it at the front : References in this part How to understand YUV ?Chrominance Subsampling in Digital Images

A picture is made up of pixels ,1920x1080 The horizontal direction has 1920 Pixels , The vertical direction has 1080 Pixels , Each pixel should contain Y、U、V The three components , But in the second sampling of chromaticity , Will make Y Share the weight UV component , That's when YUV422、YUV420 Names such as .

Long pictures are not good screenshots , Cut into many paragraphs , The following figure illustrates two sampling representation modes .
A box is used on the left to represent a pixel , Each small square, whether blackened or not, contains a Y component , The blackened boxes share a set of chrominance components ( namely U+V component ), And that little black dot represents the chromaticity Center ( No dice , It's just convenient to see ).

On the right is Secondary sampling mode marking method , namely J:a:b notation . The rectangular box in the figure is a Reference block , The dots in the box represent a pixel , Black means Y、U、V There are , Without blackening, it only contains Y component , As for the right angle symbol in the upper left corner, it means that the reference block is in the upper left corner . The size of the reference block , Generally, the height is taken as 2 Pixels , The width is J Usually take 4 Pixel point , If you look closely, you will find two numbers on the left of the reference block , These two numbers represent the number of black dots in each line .

Actually ,YUV420 These numbers are followed by 4x2 The reference block of . You can observe the small number on the left of the reference block below .
 Insert picture description here

1、YUV444

 Insert picture description here
Above, YUV444 Sampling model , It can be seen from the left and right pictures that each pixel has a pair UV component , This is equivalent to not doing chroma secondary sampling at all . Per one Y Corresponding to a group of UV component .

2、YUV440

 Insert picture description here
Above, YUV440 Sampling model , As can be seen from the left figure, each pixel in the horizontal direction has UV component , In the vertical direction, every two pixels share a pair UV component ; On the right is the first line 4 All black , On the second line, four are all white . That is, every two Y Corresponding to a group of UV component .

3、YUV422

 Insert picture description here
Above, YUV422 Sampling model , As can be seen from the left figure, each pixel in the vertical direction has UV component , In the horizontal direction, every two pixels share a pair UV component ; The picture on the right shows two black and two white lines . That is, every two Y Corresponding to a group of UV component .

4、YUV420

 Insert picture description here
Above, YUV420 Sampling model , As can be seen from the left figure, four pixels share a pair UV component , In the horizontal direction, every two pixels share a pair UV component , In the vertical direction, every two pixels also contain a pair of UV component ; The picture on the right shows two black and two white in the first line , The second line is all white . That is, every four Y Corresponding to a group of UV component .

5、YUV411

 Insert picture description here
Above, YUV411 Sampling model , It can be seen from the left figure that every four pixels share a pair in the horizontal direction UV component , In the vertical direction, each pixel contains a pair of UV component ; The picture on the right shows that the two lines are one black and three white . That is, every four Y Corresponding to a group of UV component .

6、YUV410

 Insert picture description here
Above, YUV410 Sampling model , As can be seen from the left figure 8 Pixels share a pair UV component , In the horizontal direction, every four pixels share a pair UV component , In the vertical direction, every two pixels share a pair UV component ; The picture on the right shows that only the first line has one black and the other is all white . That is, every eight Y Corresponding to a group of UV component .

3、 ... and 、YUV Data arrangement format

1、 Four kinds of data arrangement

①Planar Format

Planar Of YUV Format , That is to say, the flat storage format first continuously stores the data of all pixels Y, And then it stores all the pixels U or V, Finally store the rest U perhaps V. for example YU12( Also called I420), Belong to YUV420p, Four pixels share a group UV component ; Its data arrangement is :
Y1Y2Y3Y4Y5Y6Y7Y8 U1U2 V1V2( Here's the picture )

②Semi-Planar Format

Semi-Planar Of YUV Format , seeing the name of a thing one thinks of its function , Half plane storage format , That is, to store all the data continuously first Y component , Then interleave storage U and V component . for example NV12, Belong to YUV420sp, Four pixels share a group UV component ; Its data arrangement is :
Y1Y2Y3Y4Y5Y6Y7Y8 U1V1 U2V2( Here's the picture )
He also has a brother NV21, Its data arrangement is :
Y1Y2Y3Y4Y5Y6Y7Y8 V1U1 V2U2

③Tiled Semi-Planar Format

Tiled Semi-Planar Of YUV Format ,Tiled SP Format no longer arranges data in raster scanning order , Instead, the image is divided into macroblocks ( for example 16x16 The pixel is a macroblock ), Macroblock partition is from left to right 、 The order from top to bottom , Here's the picture . A macroblock is a square pixel area , If the sampling format is YUV420sp, Then the pixel area will be divided into NV12/NV21 Format store ( This is in doubt , I haven't seen any specific articles yet ), This is true for every macroblock , And the memory between macroblocks is continuous .

④Interleaved Format

Interleaved Of YUV Format , Also called Packed Format, In this format YUV Data is interleaved . Take a chestnut ,UYVY, Belong to YUV422 sampling , Every two pixels in the horizontal direction share a group UV component ; Its data arrangement is :
U1Y1V1Y2 U2Y3V2Y4

2、 Commonly used YUV Format Introduction

This article is all in the small end mode , The left end is the low byte .

①YV12、YU12 Format ( Belong to YUV420 Planar)

YU12 Data arrangement format :Y1Y2Y3Y4Y5Y6Y7Y8 U1U2 V1V2
YV12 Data arrangement format :Y1Y2Y3Y4Y5Y6Y7Y8 V1V2 U1U2

②NV12、NV21 Format ( Belong to YUV420 Semi-Planar)

above 3.1.2 I told you .

③UYVY、VYUY、YUYV、YVYU( Belong to YUV422 Packed)

UYVY Data arrangement format :U1Y1V1Y2 U2Y3V2Y4
For the other three, just change the order .

④AYUV( Belong to YUV444 Packed)

A Is the transparency component , The data arrangement format is A、Y、U、V Sequential storage , Each component 8bit.

⑤P010、P016( Belong to YUV420 Semi-Planar)

The four types introduced above YUV Format , Each component accounts for 8bit, and P010 Format each component accounts for 10bit,P016 Each component accounts for 16bit, That's it . Their data storage format is the same as NV12 Agreement , It's just Y、U、V Occupied bit The number is different .

⑥P210、P216( Belong to YUV422 Semi-Planar)

Same as ⑤,P210 yes 10bit Of ,P216 yes 16bit Of , These two are also Semi-Planar Of , Data storage format and NV12 Agreement .

⑦Y210、Y216( Belong to YUV422 Packed)

Y210 yes 10bit Of ,Y216 yes 16bit Of , These two are Packed Of . Their data storage format is :
Y1U1Y2V1 Y3U2Y4V2

⑧Y410、Y416( Belong to YUV444 Packed)

Empathy ,Y410 yes 10bit Of ,Y416 yes 16bit Of . Their data arrangement is shown in the figure below . The picture above shows 10bit The storage format of , The picture below shows 16bit The storage format of ,A On behalf of transparency (Alpha).
 Insert picture description here
 Insert picture description here
Last , About 10bit YUV There is one thing to note , Here's the picture , This is actually 10bit The reality of data storage , use 16bit Instead of 10bit, So put the lower six bit All set to 0, high 10bit Is the significant bit .
 Insert picture description here

原网站

版权声明
本文为[dongfangxingyu1]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101800596445.html