YUV 像素格式

论坛 期权论坛 脚本     
匿名网站用户   2020-12-19 17:22   34   0

1简介

YUV是种颜色编码方法,是彩色电视为了兼容黑白电视而发展起来的。在现代彩色电视系统中,通常采用三管彩色摄影机或彩色CCD摄影机进行取像,然后把取得的彩色图像信号经分色、分别放大校正后得到RGB,再经过矩阵变换电路得到亮度信号Y和两个色差信号R-Y(即U)、B-Y(即V),然后对这三个信号分别进行编码。Y就是所谓的流明(luminance),表示光的浓度且为非线性,使用伽马修正(gammacorrection)编码处理,而CB和CR则为蓝色和红色的浓度偏移量成份。

2YUV采样格式

  (1)YUV4:4:4

  YUV三个信道的抽样率相同,因此在生成的图像里,每个象素的三个分量信息完整(每个分量通常8比特),经过8比特量化之后,未经压缩的每个像素占用3个字节。

  下面的四个像素为:[Y0U0V0][Y1U1V1][Y2U2V2][Y3U3V3]

  存放的码流为:Y0U0V0Y1U1V1Y2U2V2Y3U3V3

  (2)YUV4:2:2

  每个色差信道的抽样率是亮度信道的一半,所以水平方向的色度抽样率只是4:4:4的一半。对非压缩的8比特量化的图像来说,每个由两个水平方向相邻的像素组成的宏像素需要占用4字节内存。

  下面的四个像素为:[Y0U0V0][Y1U1V1][Y2U2V2][Y3U3V3]

  存放的码流为:Y0U0Y1V1Y2U2Y3V3

  映射出像素点为:[Y0U0V1][Y1U0V1][Y2U2V3][Y3U2V3]

  (3)YUV4:1:1

  4:1:1的色度抽样,是在水平方向上对色度进行4:1抽样。对于低端用户和消费类产品这仍然是可以接受的。对非压缩的8比特量化的视频来说,每个由4个水平方向相邻的像素组成的宏像素需要占用6字节内存。

  下面的四个像素为:[Y0U0V0][Y1U1V1][Y2U2V2][Y3U3V3]

  存放的码流为:Y0U0Y1Y2V2Y3

  映射出像素点为:[Y0U0V2][Y1U0V2][Y2U0V2][Y3U0V2]

  (4)YUV4:2:0

  4:2:0并不意味着只有Y,Cb而没有Cr分量。它指得是对每行扫描线来说,只有一种色度分量以2:1的抽样率存储。相邻的扫描行存储不同的色度分量,也就是说,如果一行是4:2:0的话,下一行就是4:0:2,再下一行是4:2:0...以此类推。对每个色度分量来说,水平方向和竖直方向的抽样率都是2:1,所以可以说色度的抽样率是4:1。

  下面八个像素为:[Y0U0V0][Y1U1V1][Y2U2V2][Y3U3V3]

   [Y5U5V5][Y6U6V6][Y7U7V7][Y8U8V8]

  存放的码流为:Y0U0Y1Y2U2Y3Y5V5Y6Y7V7Y8

  映射出的像素点为:[Y0U0V5][Y1U0V5][Y2U2V7][Y3U2V7]

   [Y5U0V5][Y6U0V5][Y7U2V7][Y8U2V7]

3YUV存储格式

YUV格式分为packed格式和planar格式,packed格式会将YUV数据按顺序放进数组里,planar则分将YUV的数据分为三部分放进数组里,即先放Y部分的数据,再放U,接着是V的数据。

3.1PackedYUVFormats

Label

Bitsperpixel

Description

AYUV

32

CombinedYUVandalpha

CLJR

8

CirrusLogicformatwith4pixelspackedintoau_int32.AformofYUV4:1:1wihtlessthan8bitsperY,UandVsample.

cyuv

16

EssentiallyacopyofUYVYexceptthatthesenseoftheheightisreversed-theimageisupsidedownwithrespecttotheUYVYversion.

GREY

8

ApparentlyaduplicateofY800(andalso,presumably,"Y8")

IRAW

?

InteluncompressedYUV.Ihavenoinformationonthisformat-canyouhelp?

IUYV

16

InterlacedversionofUYVY(lineorder0,2,4,....,1,3,5....)registeredbySilviuBrinzeiofLEADTechnologies.

IY41

12

InterlacedversionofY41P(lineorder0,2,4,....,1,3,5....)registeredbySilviuBrinzeiofLEADTechnologies.

IYU1

12

12bitformatusedinmode2oftheIEEE1394DigitalCamera1.04spec.ThisisequivalenttoY411

IYU2

24

24bitformatusedinmode0oftheIEEE1394DigitalCamera1.04spec

HDYC

16

YUV4:2:2(Ysampleateverypixel,UandVsampledateverysecondpixelhorizontallyoneachline).Amacropixelcontains2pixelsin1u_int32.ThisisasuplicateofUYVYexceptthatthecolorcomponentsusetheBT709colorspace(asusedinHDvideo).

UYNV

16

AdirectcopyofUYVYregisteredbyNVidiatoworkaroundproblemsinsomeoldcodecswhichdidnotlikehardwarewhichofferedmorethan2UYVYsurfaces.

UYVP

24?

YCbCr4:2:2extendedprecision10-bitspercomponentinU0Y0V0Y1order.RegisteredbyRichEhlersofEvans&Sutherland.(Awaitingconfirmationofcomponentpackingstructure)

UYVY

16

YUV4:2:2(Ysampleateverypixel,UandVsampledateverysecondpixelhorizontallyoneachline).Amacropixelcontains2pixelsin1u_int32.

V210

32

10-bit4:2:2YCrCbequivalenttotheQuicktimeformatofthesamename.

V422

16

IamtoldthatthisisanupsidedownversionofUYVY.

V655

16?

16bitYUV4:2:2formatregisteredbyVitecMultimedia.Ihavenoinformationonthecomponentorderingorpacking.

VYUY

?

ATIPackedYUVData(formatunknownbutyoucangetholdofacodecsupportingithere)

Y422

16

DirectcopyofUYVYasusedbyADSTechnologiesPyroWebCamfirewirecamera.

YUY2

16

YUV4:2:2asforUYVYbutwithdifferentcomponentorderingwithintheu_int32macropixel.

YUYV

16

DuplicateofYUY2

YUNV

16

AdirectcopyofYUY2registeredbyNVidiatoworkaroundproblemsinsomeoldcodecswhichdidnotlikehardwarewhichofferedmorethan2YUY2surfaces.

YVYU

16

YUV4:2:2asforUYVYbutwithdifferentcomponentorderingwithintheu_int32macropixel.

Y41P

12

YUV4:1:1(Ysampleateverypixel,UandVsampledateveryfourthpixelhorizontallyoneachline).Amacropixelcontains8pixelsin3u_int32s.

Y411

12

YUV4:1:1withapacked,6byte/4pixelmacroblockstructure.

Y211

8

PackedYUVformatwithYsampledateverysecondpixelacrosseachlineandUandVsampledateveryfourthpixel.

Y41T

12

FormatasforY41PbutthelsbofeachYcomponentisusedtosignalpixeltransparency.

Y42T

16

FormatasforUYVYbutthelsbofeachYcomponentisusedtosignalpixeltransparency.

YUVP

24?

YCbCr4:2:2extendedprecision10-bitspercomponentinY0U0Y1V0order.RegisteredbyRichEhlersofEvans&Sutherland.

Y800

8

Simple,singleYplaneformonochromeimages.

Y8

8

DuplicateofY800asfarasIcansee.

Y16

16

16-bituncompressedgreyscaleimage.

UYVY存储结构

UYVY是一种最常用的YUV4:2:2格式,其数据排列如下:

3.2PlanarYUVFormats

Label

Bitsperpixel

Description

YVU9

9

8bitYplanefollowedby8bit4x4subsampledVandUplanes.RegisteredbyIntel.

YUV9

9?

RegisteredbyIntel.,thisistheformatusedinternallybyIndeovideocode

IF09

9.5

AsYVU9butanadditional4x4subsampledplaneisappendedcontainingdeltainformationrelativetothelastframe.(Bppisreportedas9)

YV16

16

8bitYplanefollowedby8bit2x1subsampledVandUplanes.

YV12

12

8bitYplanefollowedby8bit2x2subsampledVandUplanes.

I420

12

8bitYplanefollowedby8bit2x2subsampledUandVplanes.

IYUV

12

DuplicateFOURCC,identicaltoI420.

NV12

12

8-bitYplanefollowedbyaninterleavedU/Vplanewith2x2subsampling

NV21

12

AsNV12withUandVreversedintheinterleavedplane

IMC1

12

AsYV12excepttheUandVplaneseachhavethesamestrideastheYplane

IMC2

12

SimilartoIMC1exceptthattheUandVlinesareinterleavedathalfstrideboundaries

IMC3

12

AsIMC1exceptthatUandVareswapped

IMC4

12

AsIMC2exceptthatUandVareswapped

CLPL

12

FormatsimilartoYV12butincludingalevelofindirection.

Y41B

12?

Weitekformatlistedas"YUV4:1:1planar".Ihavenootherinformationonthisformat.

Y42B

16?

Weitekformatlistedas"YUV4:2:2planar".Ihavenootherinformationonthisformat.

Y800

8

Simple,singleYplaneformonochromeimages.

Y8

8

DuplicateofY800asfarasIcansee.

CXY1

12

Awaitingclarificationofformat.

CXY2

16

Awaitingclarificationofformat.

Y42B存储结构

YCbCr4:2:2的方式存储

4YUVRGB的转换关系

yuv422planartorgb565
转换公式:
R=Y+1.4075*(V-128)
G=Y-0.3455*(U-128)-0.7169*(V-128)
B=Y+1.779*(U-128)
为了加快运算速度,采用下面的整形计算法:
u=YUVdata[UPOS]-128;
v=YUVdata[VPOS]-128;

rdif=v+((v*103)>>8);
invgdif=((u*88)>>8)+((v*183)>>8);
bdif=u+((u*198)>>8);

r=YUVdata[YPOS]+rdif;
g=YUVdata[YPOS]-invgdif;
b=YUVdata[YPOS]+bdif;
r=r>255?:255:(r<0:?0:r);
g=g>255?:255:(g<0:?0:g);
b=b>255?:255:(b<0:?0:b);
以上得到的是rgb888的数据,再将rgb888转为rgb555
RGBdata[1]=((r&0xF8)|(g>>5));
RGBdata[0]=(((g&0x1C)<<3)|(b>>3));
YUV422PlanarFORMATsize:
size=width*height*2;
YSIZE=size/2;
USIZE=size/4;
VSIZE=size/4;
YPOS=0;
UPOS=YPOS+size/2;
VPOS=UPOS+size/4;

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:1136255
帖子:227251
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP