YUV格式分析

 

YUV简介

YUV ,是一种颜色 编码 方法。

YUV是编译true-color颜色空间(color space)的种类,Y'UV, YUV, YCbCrYPbPr 等专有名词都可以称为YUV,彼此有重叠。“Y”表示明亮度 (Luminance、Luma),“U”和“V”则是色度 浓度 (Chrominance、 Chroma),Y'UV, YUV, YCbCr, YPbPr 常常有些混用的情况,其中 YUV 和 Y'UV 通常用来描述类比讯号,而相反的 YCbCr 与 YPbPr 则是用来描述数位的影像讯号,例如在一些压缩格式内 MPEG、JPEG 中,但在现今,YUV 通常已经在电脑系统上广泛使用。YUV Formats分成两个格式:

  • 紧缩格式(packed formats):将Y、U、V值储存成Macro Pixels阵列,和RGB 的存放方式类似。
  • 平面格式(planar formats):将Y、U、V的三个份量分别存放在不同的矩阵中。

紧缩格式(packed format)中的YUV是混合在一起的,对于YUV4:4:4格式而言,用紧缩格式很合适的,因此就有了UYVY、YUYV等。平面格式(planar formats)是指每Y份量,U份量和V份量都是以独立的平面组织的,也就是说所有的U份量必须在Y份量后面,而V份量在所有的U份量后面,此一格式适 用于采样(subsample)。平面格式(planar format)有I420(4:2:0)、YV12、IYUV等。

 

常用的YUV格式

为节省带宽起见,大多数 YUV 格式平均使用的每像素位数都少于24位元。主要的采样(subsample)格式有YCbCr 4:2:0、YCbCr 4:2:2、YCbCr 4:1:1和 YCbCr 4:4:4。YUV的表示法称为 A:B:C 表示法:

  • 4:4:4 表示完全取样。
  • 4:2:2 表示 2:1 的水平取样,没有垂直下采样。
  • 4:2:0 表示 2:1 的水平取样,2:1 的垂直下采样。
  • 4:1:1 表示 4:1 的水平取样,没有垂直下采样。

最常用Y:UV记录的比重通常 1:1 或 2:1,DVD-Video 是以 YUV 4:2:0 的方式记录,也就是我们俗称的I420 ,YUV4:2:0 并不是说只有U(即 Cb), V(即 Cr)一定为 0,而是指U:V互相援引,时见时隐,也就是说对于每一个行,只有一个U或者V份量,如果一行是4:2:0的话,下一行就是4:0:2,再下一行是 4:2:0...以此类推。至于其他常见的YUV格式有YUY2、YUYV、YVYU、UYVY、AYUV、Y41P、Y411、Y211、IF09、 IYUV、YV12、YVU9、YUV411、YUV420等。

YUV 编码方式

(1) YUV 4:4:4
YUV三个信道的抽样率相同,因此在生成的图像里,每个象素的三个分量信息完整,如果每个分量用8比特表示,则未经压缩的每个像素占用3个字节。
原始像素为         [Y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]
采样后的码流为    [Y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]    (4:4:4)
还原后的像素为    [Y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]

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

原始像素为:       [Y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]
采样后的码流为:  [Y0 U0    ] [Y1    V1  ] [Y2 U2    ] [Y3      V3]    (4:2:2)
还原后的像素为:  [Y0 U0 V1] [Y1 U0 V1] [Y2 U2 V3] [Y3 U2 V3]

(3) YUV 4:1:1
4:1:1的色度抽样,是在水平方向上对色度进行4:1抽样。对于低端用户和消费类产品这仍然是可以接受的。对非压缩的8比特量化的视频来说,每个由4个水平方向相邻的像素组成的宏像素需要占用6字节内存
原始像素为:       [Y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]
采样后的码流为:  [Y0 U0    ] [Y1         ] [Y2      V2] [Y3         ]    (4:1:1)
映射出像素点为:  [Y0 U0 V2] [Y1 U0 V2] [Y2 U0 V2] [Y3 U0 V2]

(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。对非压缩的8比特量化的视频来说,每个由2x2个2行2列相邻的像素组成的宏像素需要占用6字节内存。
原始像素为:        [Y0 U0 V0] [Y1 U1 V1] [Y2 U2 V2] [Y3 U3 V3]
                        [Y4 U4 V4] [Y5 U5 V5] [Y6 U6 V6] [Y7 U7 V7]
采样后的码流为:   [Y0 U0     ] [Y1        ] [Y2 U2     ] [Y3          ]  (4:2:0)
                        [Y4      V4] [Y5        ] [Y6      V6] [Y7          ]  (4:0:2)
映射出的像素点为:[Y0 U0 V4] [Y1 U0 V4] [Y2 U2 V6] [Y3 U2 V6] 
                        [Y4 U0 V4] [Y5 U0 V4] [Y6 U2 V6] [Y7 U2 V6]

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UVTools are a set of software utilities to play, convert and analyze YUV or RGB video data in their raw formats. The main features of YUVTools are: It accepts (plays, converts, edits and analyzes) the combination of following formats: YUV in 4:4:4, 4:2:2 or 4:2:0 sample format, RGB in 4:4:4 sampling format; in different component order, like YUV, YVU, UYV, RGB, BGR, etc. in progressive (one single frame) or interlaced (two fields) format; in planar (YYY...UUU...VVV...) or packed (YUV, YUV....) pixel format; in predefined or arbitrary resolutions; Support FOURCC ( refer to: http://www.fourcc.org/). An image preview function to help guess the video format interactively. YUV Player can open multiple player dialogs and play different files in each dialog separately, or play multiple video files in one player dialog one by one sequentially. The detailed format of any opened or generated files will be logged, and the user can directly select any file to play back from the history list. YUV Converter can convert any combination of the format to another format, or convert to (or from) a sequence of BMP files. Other conversion functions include: scaling, join, crop, flip, padding, merge and separation of color components. YUV Analyzer can be used to calculate PSNR between two YUV files, or compare pixel by pixel to check the difference between the corresponding frames of two files, or overlay block type or motion vectors on top of each frame. Another useful feature is to help check the motion between two adjacent frames. YUV Editor can be used to edit the images pixel by pixel, or overlay one YUV image on top of another YUV image file. Convert YUV file to AVI format or vice versa; Setting options include grid display, different YUV to RGB conversion formula, etc. Many of above functions can also be performed in command line mode, which are useful for batch process or scripting.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值