Detailed explanation of YUV format-the most complete in history

Introduction

I am afraid that no one in the audio and video field does not know YUV, but YUV itself has many variants with various names. This article is in place to summarize the various formats of YUV.

Before we start, let me introduce you a YUV image viewing tool—YUV Eye. You can use this tool to view YUV images. Sometimes when debugging, it is much more convenient to have such a tool.

https://www.zzsin.com/YUVEye.html
Insert picture description here

First introduce YUV, as we all know, YUV is a model that represents color. But what we often say of YUV actually refers to YCbCr, where Y refers to the brightness component, Cb refers to the blue chroma component, and Cr refers to the red chroma component, which is a copy of the standard YUV. In this article, we use YUV to refer to Replaced YCbCr.

Let's look at the common format of YUV again. You must have read many articles about the YUV format, but there may not be a systematic understanding of which formats exist in YUV, which variants of each format, and which aliases. It doesn't matter, we use this article to help you summarize and analyze.

Let's classify the advanced nature of the YUV format. You can refer to the figure below.

Insert picture description here

Classification standard

First, we can divide the YUV format into three formats according to the data size, YUV 420, YUV 422, and YUV 444. Because the human eye is more sensitive to Y than to U and V, sometimes multiple Y components can share a set of UV, which can save space greatly without losing quality. These three formats are formulated according to the characteristics of the human eye.

  • YUV 420, with 4 Y components sharing a set of UV components,
  • YUV 422, two Y components share a set of UV components
  • YUV 444, not shared, one Y component uses a set of UV components

According to the way that multiple Y components share one UV, we can divide YUV into three types: 420, 422, and 444, and under these three types, we can subdivide it into YUV according to the order of storage There are a lot of formats, these formats are numerous, and they are not easy to remember, which caused a lot of difficulties in our learning process. Let me introduce them one by one.

First of all, we will be able to divide YUV into three categories again according to the arrangement of YUV, Planar, Semi-Planar and Packed.

  • Three components of Planar YUV are stored separately
  • Semi-Planar Y components are stored separately, UV components are staggered
  • Packed YUV all three components are interleaved

According to these three methods, we can classify the YUV format in more detail.

Specific classification

I420 (belongs to YUV 420 Plannar)

I420 is a kind of YUV 420 Planar. The YUV components are stored separately. First is Y of w * h length, followed by U of w * h * 0.25 length, and finally V of w * h * 0.25 length. The total length is w * h * 1.5.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V V V
V V V
V V V

YV12 (belongs to YUV 420 Plannar)

YV12 is a kind of YUV 420 Planar. The YUV components are stored separately. First is Y of w * h length, followed by V of w * h * 0.25 length, and finally U of w * h * 0.25 length, the total length is w * h * 1.5. Different from I420, YV12 is V first, then U

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V V V
U U U
U U U
U U U

NV12 (belongs to YUV 420 Semi-Planar)

NV12 is a kind of YUV 420 Semi-Planar. The Y component is stored separately and the UV component is stored staggered. When the UV is arranged, it starts from U. The total length is w * h * 1.5.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
U V U V U V

NV21 (belongs to YUV 420 Semi-Planar)

NV21 is a kind of YUV 420 Semi-Planar. The Y component is stored separately and the UV component is stored staggered. Unlike NV12, when the UV is arranged, it starts from V. The total length is w * h * 1.5.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V U V U V U

I422 (belongs to YUV 422 Plannar)

I422 is a kind of YUV 422 Planar. The YUV components are stored separately. First is Y with length w * h, followed by U with length w * h * 0.5, and finally V with length w * h * 0.5, the total length is w * h * 2.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V V V V V V
V V V V V V
V V V V V V

YV16 (belongs to YUV 422 Plannar)

YV16 is a kind of YUV 422 Planar. The YUV components are stored separately. First is Y of w * h length, followed by V of w * h * 0.5 length, and finally U of w * h * 0.5 length, and the total length is w * h * 2. Different from I422, YV16 is V first, U

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V V V V V V
V V V V V V
U U U U U U
U U U U U U
U U U U U U

NV16 (belongs to YUV 422 Semi-Planar)

NV16 is a kind of YUV 422 Semi-Planar. The Y component is stored separately and the UV component is stored staggered. When the UV is arranged, it starts from U. The total length is w * h * 2.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
U V U V U V
U V U V U V
U V U V U V
U V U V U V

NV61 (belongs to YUV 422 Semi-Planar)

NV61 is a kind of YUV 422 Semi-Planar. The Y component is stored separately and the UV component is stored staggered. When the UV is arranged, it starts from V. The total length is w * h * 2.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V U V U V U
V U V U V U
V U V U V U
V U V U V U

YUVY (belongs to YUV 422 Interleaved)

YUVY is a kind of YUV 422 Interleaved. In fact, Interleaved belongs to Packed, but in 422, Interleaved is more vivid. Inside Packed, the sequence of YUV is YUVY, and two Ys share a set of UV.

Y U V Y   Y U V Y   Y U V Y
Y U V Y   Y U V Y   Y U V Y
Y U V Y   Y U V Y   Y U V Y
Y U V Y   Y U V Y   Y U V Y
Y U V Y   Y U V Y   Y U V Y
Y U V Y   Y U V Y   Y U V Y
  • VYUY (belongs to YUV 422 Interleaved)
    VYUY is a kind of YUV 422 Interleaved. Inside Packed, the sequence of YUV is VYUY, and two Ys share a set of UV.
V Y U Y   V Y U Y   V Y U Y
V Y U Y   V Y U Y   V Y U Y
V Y U Y   V Y U Y   V Y U Y
V Y U Y   V Y U Y   V Y U Y
V Y U Y   V Y U Y   V Y U Y
V Y U Y   V Y U Y   V Y U Y

UYVY (belongs to YUV 422 Interleaved)

UYVY is a kind of YUV 422 Interleaved. Inside Packed, the sequence of YUV is UYVY, and two Ys share a set of UVs.

U Y V Y   U Y V Y   U Y V Y
U Y V Y   U Y V Y   U Y V Y
U Y V Y   U Y V Y   U Y V Y
U Y V Y   U Y V Y   U Y V Y
U Y V Y   U Y V Y   U Y V Y
U Y V Y   U Y V Y   U Y V Y

I444 (belongs to YUV 444 Plannar)

I444 is a kind of YUV 444 Plannar. The YUV components are stored separately, first is Y of w * h length, followed by U of w * h length, and finally V of w * h length, the total length is w * h * 3.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
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
V V V V V V
V V V V V V

YV24 (belongs to YUV 444 Plannar)

YV24 is a kind of YUV 444 Plannar. The YUV components are stored separately, firstly Y of w * h length, followed by V of w * h length, and finally U of w * h length, with a total length of w * h * 3. Different from I444, YV24 arranges V first.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V V V V V V
V V V V V V
V V V V V V
V V V V V V
V V V V V V
U U U U U U
U U U U U U
U U U U U U
U U U U U U
U U U U U U
U U U U U U

NV24 (belongs to YUV 444 Semi-Planar)

NV24 is a kind of YUV 444 Semi-Planar. The Y component is stored separately and the UV component is staggered. When the UV is arranged, it starts from U. The total length is w * h * 3.

Y Y Y Y Y Y
Y Y Y Y Y Y
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 
U V U V U V U V U V U V 
U V U V U V U V U V U V 
U V U V U V U V U V U V 
U V U V U V U V U V U V 
U V U V U V U V U V U V 

NV42 (belongs to YUV 444 Semi-Planar)

NV42 is a kind of YUV 444 Semi-Planar. The Y component is stored separately and the UV component is staggered. When the UV is arranged, it starts from V. The total length is w * h * 3.

Y Y Y Y Y Y
Y Y Y Y Y Y
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
V U V U V U V U V U V U
V U V U V U V U V U V U
V U V U V U V U V U V U
V U V U V U V U V U V U
V U V U V U V U V U V U
  • YUV 444 Packed
    will not be explained. . .
Y U V   Y U V   Y U V   Y U V   Y U V   Y U V
Y U V   Y U V   Y U V   Y U V   Y U V   Y U V
Y U V   Y U V   Y U V   Y U V   Y U V   Y U V
Y U V   Y U V   Y U V   Y U V   Y U V   Y U V
Y U V   Y U V   Y U V   Y U V   Y U V   Y U V
Y U V   Y U V   Y U V   Y U V   Y U V   Y U V

Finally, add an audio and video QQ exchange group~~~

814462428

Guess you like

Origin blog.csdn.net/miaoyuqiao/article/details/112987179