Audio and video data study notes -YUV

YUV data types

  • h264 coding, we use the YUV data types for transmission, from the collection end of the transfer YUV RGB collected, transmitted over a network to a receiving end, sub YUV to RGB for display.
  • During the compression of the data relates to, RGB-> YUV data, the size ratio of 2: 1, i.e. occupied RGB data size (Width * Height) * 3, since a required pixel data representing red, yellow, blue, and YUV data is only necessary (Width * Height) * 3/2, because the YUV each pixel has a Y (luminance) data, and is typically a 4: 2: 0 ratio, i.e., four Y share one and 1 U V. compared to the original 4: 4: 4 (Y 1 with the U-1, 1 V), compared with half the amount of memory.
  • For YUV data, the distribution of the original YUV 4: 4: 4, but the human eye to changing the luminance (Y) is more sensitive to chrominance (UV also referred The CrCb) is not sensitive, so that when the storage portion discarded color degree data, to achieve the purpose of compression.
    Here Insert Picture Description
    Here is Y0Y1Y6Y7 share U0V0, why is not it U0V0 Y0Y1Y2Y3 share, which is about the H264 compression technology, within a macro block, close to the word block course chrominance difference minimum value, I think so.
    H264 basic principle https://www.jianshu.com/p/97b4dc8c7f00
    this text is very well written

I420 and YV12

Both of which are of planar data format, and on planar Packet, the forth herein:
planar Mode Example: Y0Y1 ... Yn U0U1 ... Um V0V1 ... Vm, YUV three channels are successively stored;
Packet Mode Example: Y0U0V0 + Y1U1V1 + ... + YnUnVn, YUV three-channel hybrid storage.
I420 data we receive 3 channels, especially in the code, we'll get the data one by one single plane.

i420 data arrangement

i420 data arrangement is Y0Y1 ... Yn + U0U1 ... Un + V0V1 ... Vn
i.e. acquired char * data type of data, the order is Y, U and then immediately V.
Since the data size of Y, according to 4: 2 : Get 0, a length of w i d t h h e i g h t width *height , because the total length of w i d t h h e i g h t 3 / 2 width *height*3/2 . This has been described above.
U and V is a size 1/4 of the length Y, can be removed from the address and length.

Data arrangement YV12

With the i420 is not the same, in reverse order U and V.
YV12 data arrangement is Y0Y1 ... Yn + V0V1 ... Vn + U0U1 ... Un

NV12 and NV21

The data are arranged NV12 + Yn of U0V0U1V1 ... ... Y0Y1 UnVn
NV21 data are arranged Y0Y1 ... Yn + V0U0V1U1 ... VnUn
difference is that a different order of UV, with different i420, UV is stored attached together.

Like other data types Principle yuv

Guess you like

Origin blog.csdn.net/shengpeng3344/article/details/91978644