display:YUV各種格式所佔字節數

YUV與RGB大致的轉換方式

R=Y+1.140*V
G=Y-0.395*U-0.581*V
B=Y+2.032*U

Y=+0.299*R+0.587*G+0.114*B
U=-0.147*R-0.289*G+0.436*B
V=+0.615*R-0.515*G-0.100*B

 

YUV is a class of pixel formats used in video applications, including VLC media player.

YUV is actually the name of the color space that is common to all "YUV" pixel formats. Contrary to RGB formats (Red-Green-Blue), YUV colors are represented with one "luminance" component called Y (equivalent to grey scale) and two "chrominance" components, called U (blue projection) and V (red projection) respectively, hence the name.

YUV can also be referred to as YCbCr, although the terms mean slightly different things,[note 1] they tend to be confused and used interchangeably (including in VLC-related venues).

This page explains the most useful YUV pixel formats in the context of VLC media player. Unless otherwise stated, values for each component are stored in one octet (8 bits).
Contents

Planar formats

Planar (or sometimes "triplanar") formats use separate matrices for each of the 3 color components. In other words, there is one table of luminance pixel values, and two separate tables for the chrominance components. This segregated representation in memory of pixels is more convenient for video coding.
YUV 4:2:0 (I420/J420/YV12)
I420

It has the luma "luminance" plane Y first, then the U chroma plane and last the V chroma plane.

The two chroma planes (blue and red projections) are sub-sampled in both the horizontal and vertical dimensions by a factor of 2. That is to say, for a 2×2 square of pixels, there are 4 Y samples but only 1 U sample and 1 V sample.

This format requires 4×8+8+8=48 bits per 4 pixels, so its depth is 12 bits per pixel.

I420 is by far the most common format in VLC. Most video decoders output raw pictures in I420 format.

A graphical illustration: Each letter represents one bit.

    For a single I420 pixel: YYYYYYYY UU VV
    For a 50-pixel I420 frame: YYYYYYYY×50 UU×50 VV×50 (or Y×8×50 U×2×50 V×2×50 for short)
    For an n-pixel I420 frame: Y×8×n U×2×n V×2×n 

J420

J420 is exactly like I420, but with a full range ("digital", 0-255) luma (Y) component instead of limited range ("analog", 16-240). The chroma planes are exactly the same as in I420.
YV12

YV12 is exactly like I420, but the order of the U and V planes is reversed. In the name, "YV" refers to the plane order: Y, then V (then U). "12" refers to the pixel depth: 12-bits per pixel as for I420.
YUV 4:2:2 (I422/J422)
I422

Like I420, I422 has one luma plane Y and 2 chroma planes U, V.

However, in I422, chroma planes (blue and red projections) are sub-sampled only in the horizontal dimension, still by a factor of 2. Thus, there is the same amount of lines in chroma planes as in the luma plane.

For a 2×2 group of pixels, there are 4 Y samples and 2 U and 2 V samples each. The depth is 4×8+2×8+2×8=64 bits per 4 pixels, so 16 bits per pixel.

Some video codecs support I422 (optionally) for higher quality video encoding.
J422

J422 is exactly like I422, but with a full range ("digital", 0-255) luma (Y) component instead of limited range ("analog", 16-240). The chroma planes are exactly the same as in I422.
YUV 4:4:4
I444

As I420 and I422, I444 has one luma plane Y and 2 chroma planes U and V. Chroma planes are not sub-sampled: there are 3 octet values for each pixels. The depth is thus 24 bits per pixel (as with RGB24 or RGB32).

A few video codecs support I444 optionally.
Packed formats

In packed formats, you usually have only one plane, with all the luma and chroma data interleaved. This is similar to RGB pixel formats, only using a different color space.

Packed formats are very popular inside webcams. In hardware, using separate planes is inefficient: several memory accesses are needed for each pixel. Packed formats are easier and thus cheaper to use.

On the other hand, packet formats cannot normally deal with vertical sub-sampling. Otherwise scan lines would have different sizes. So generally, packed formats are horizontally subsampled, especially by a factor of 2 (i.e., YUV 4:2:2).
UYVY

Known as UYVY, Y422 or UYNV.

In UYVY, the chroma samples are sub-sampled by a factor of 2.

In UYVY, the succession for 2 pixels, starts by U then one luma if the first pixel, then V and then another luma for the second pixel.
YUY2

Known as YUY2, YUYV, V422 or YUNV.

In YUY2, the chroma samples are sub-sampled by a factor of 2.

In YUY2, the succession for 2 pixels, starts by one luma for the first pixel, then U, then another luma for the second pixel and then V again.

Conversion between YUY2 and UYVY is achieved by swapping bytes pairwise.
YVYU

YVYU is just like YUY2, but with U and V order reversed.
VYUV

TBD.
Semi-planar

Semi planar formats have two planes instead of three, one plane for luminance, and one plane for both chrominance components. They are also sometimes referred to as biplanar formats also.
NV12/NV21
NV12

Related to I420, NV12 has one luma "luminance" plane Y and one plane with U and V values interleaved.

In NV12, chroma planes (blue and red) are subsampled in both the horizontal and vertical dimensions by a factor of 2.

For a 2×2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.

It can be helpful to think of NV12 as I420 with the U and V planes interleaved.

Here is a graphical representation of NV12. Each letter represents one bit:

    For 1 NV12 pixel: YYYYYYYY UVUV
    For a 2-pixel NV12 frame: YYYYYYYYYYYYYYYY UVUVUVUV
    For a 50-pixel NV12 frame: Y×8×50 (UV)×2×50
    For a n-pixel NV12 frame: Y×8×n (UV)×2×n 

NV21

NV21 is like NV12, but with U and V order reversed: it starts with V.
Other NV formats

Following the same pattern as NV12/NV21, there are NV16/NV61 (4:2:2 sub-sampling) and NV24/NV42 (4:4:4 sampling) formats. They are mostly used in some funky cheap camera circuitry and not supported in VLC (as of VLC version 2.0).
Notes

    ^ note 1 Technical details are generally understood from context. Everything described on this page is Y′CbCr, not Y′UV.
    Y′CbCr chroma subsampling formats (e.g. 4:2:0) are used only for digital signals; VLC deals with digital signals.
    In many cases: Y′UV is for analog signals, Y′PbPr for analog signals in video component cables; Y′CbCr for digital signals (including MPEG-2). Gamma correction is indicated by a prime ′, thus gamma-corrected YCbCr is written Y′CbCr. For an extended discussion see YUV and luminance considered harmful or Color FAQ § What are colour differences? by Charles Poynton 

Further reading

    https://fourcc.org/yuv.php 

Packed YUV Formats
Label 	FOURCC in Hex 	Bits per pixel 	Description
AYUV	0x56555941	32	Combined YUV and alpha
CLJR	0x524A4C43	8	Cirrus Logic format with 4 pixels packed into a u_int32. A form of YUV 4:1:1 wiht less than 8 bits per Y, U and V sample.
CYUV	0x76757963	16	Essentially a copy of UYVY except that the sense of the height is reversed - the image is upside down with respect to the UYVY version.
GREY
(Y800)	0x59455247	8	Apparently a duplicate of Y800 (and also, presumably, "Y8 ")
HDYC
(UYVY)	0x43594448	16	YUV 4:2:2 (Y sample at every pixel, U and V sampled at every second pixel horizontally on each line). A macropixel contains 2 pixels in 1 u_int32. This is a suplicate of UYVY except that the color components use the BT709 color space (as used in HD video).
IRAW	0x57615349	?	Intel uncompressed YUV. I have no information on this format - can you help?
IUYV
(UYVY)	0x56595549	16	Interlaced version of UYVY (line order 0, 2, 4,....,1, 3, 5....) registered by Silviu Brinzei of LEAD Technologies.
IY41	0x31555949	12	Interlaced version of Y41P (line order 0, 2, 4,....,1, 3, 5....) registered by Silviu Brinzei of LEAD Technologies.
IYU1	0x31555949	12	12 bit format used in mode 2 of the IEEE 1394 Digital Camera 1.04 spec. This is equivalent to Y411
IYU2	0x32555949	24	24 bit format used in mode 0 of the IEEE 1394 Digital Camera 1.04 spec
UYNV
(UYVY)	0x564E5955	16	A direct copy of UYVY registered by NVidia to work around problems in some old codecs which did not like hardware which offered more than 2 UYVY surfaces.
UYVP	0x50565955	24?	YCbCr 4:2:2 extended precision 10-bits per component in U0Y0V0Y1 order. Registered by Rich Ehlers of Evans & Sutherland.
UYVY	0x59565955	16	YUV 4:2:2 (Y sample at every pixel, U and V sampled at every second pixel horizontally on each line). A macropixel contains 2 pixels in 1 u_int32.
V210	0x30313256	32	10-bit 4:2:2 YCrCb equivalent to the Quicktime format of the same name.
V422	0x32323456	16	I am told that this is an upside down version of UYVY.
V655	0x35353656	16?	16 bit YUV 4:2:2 format registered by Vitec Multimedia. I have no information on the component ordering or packing.
VYUY	0x59555956	?	ATI Packed YUV Data (format unknown)
Y16	0x20363159	16	16-bit uncompressed greyscale image.
Y211	0x31313259	8	Packed YUV format with Y sampled at every second pixel across each line and U and V sampled at every fourth pixel.
Y411	0x31313459	12	YUV 4:1:1 with a packed, 6 byte/4 pixel macroblock structure.
Y41P	0x50313459	12	YUV 4:1:1 (Y sample at every pixel, U and V sampled at every fourth pixel horizontally on each line). A macropixel contains 8 pixels in 3 u_int32s.
Y41T	0x54313459	12	Format as for Y41P but the lsb of each Y component is used to signal pixel transparency .
Y422
(UYVY)	0x32323459	16	Direct copy of UYVY as used by ADS Technologies Pyro WebCam firewire camera.
Y42T	0x54323459	16	Format as for UYVY but the lsb of each Y component is used to signal pixel transparency .
Y8
(Y800)	0x20203859	8	Duplicate of Y800 as far as I can see.
Y800	0x30303859	8	Simple, single Y plane for monochrome images.
YUNV
(YUY2)	0x564E5559	16	A direct copy of YUY2 registered by NVidia to work around problems in some old codecs which did not like hardware which offered more than 2 YUY2 surfaces.
YUVP	0x50565559	24?	YCbCr 4:2:2 extended precision 10-bits per component in Y0U0Y1V0 order. Registered by Rich Ehlers of Evans & Sutherland.
YUY2	0x32595559	16	YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel.
YUYV
(YUY2)	0x56595559	16	Duplicate of YUY2
YVYU	0x55595659	16	YUV 4:2:2 as for UYVY but with different component ordering within the u_int32 macropixel.
Planar YUV Formats
Label 	FOURCC in Hex 	Bits per pixel 	Description
CLPL	0x4C504C43	12	Format similar to YV12 but including a level of indirection.
CXY1	0x31595843	12	Planar YUV 4:1:1 format registered by Conexant.
CXY2	0x32595842	16	Planar YUV 4:2:2 format registered by Conexant.
I420	0x30323449	12	8 bit Y plane followed by 8 bit 2x2 subsampled U and V planes.
IF09	0x39304649	9.5	As YVU9 but an additional 4x4 subsampled plane is appended containing delta information relative to the last frame. (Bpp is reported as 9)
IMC1	0x31434D49	12	As YV12 except the U and V planes each have the same stride as the Y plane
IMC2	0x32434D49	12	Similar to IMC1 except that the U and V lines are interleaved at half stride boundaries
IMC3
(IMC1)	0x33434D49	12	As IMC1 except that U and V are swapped
IMC4
(IMC2)	0x34434D49	12	As IMC2 except that U and V are swapped
IYUV
(I420)	0x56555949	12	Duplicate FOURCC, identical to I420.
NV12	0x3231564E	12	8-bit Y plane followed by an interleaved U/V plane with 2x2 subsampling
NV21	0x3132564E	12	As NV12 with U and V reversed in the interleaved plane
Y41B	0x42313459	12?	Weitek format listed as "YUV 4:1:1 planar". I have no other information on this format.
Y42B	0x42323459	16?	Weitek format listed as "YUV 4:2:2 planar". I have no other information on this format.
Y8
(Y800)	0x20203859	8	Duplicate of Y800 as far as I can see.
Y800	0x30303859	8	Simple, single Y plane for monochrome images.
YUV9	0x39565559	9?	Registered by Intel., this is the format used internally by Indeo video code
YV12	0x32315659	12	8 bit Y plane followed by 8 bit 2x2 subsampled V and U planes.
YV16	0x36315659	16	8 bit Y plane followed by 8 bit 2x1 subsampled V and U planes.
YVU9	0x39555659	9	8 bit Y plane followed by 8 bit 4x4 subsampled V and U planes. Registered by Intel.

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章