YUV使用总结 —— Android常用的几种格式:NV21/NV12/YV12/YUV420P的区别

本文详细介绍了Android中两种常见的YUV格式——NV21和YV12,包括它们的内存布局、数据存储方式以及如何进行处理。在Android API <= 20,Camera Preview Callback支持的YUV格式主要是NV21和YV12,这两种格式都是12位像素,Y值和UV值以planar形式独立存储。NV12的UV值是以每个像素点的LSB为U,MSB为V的方式打包在一起,而YV12则将所有Y值存储后,接着是所有的V值,最后是U值。了解这些格式对于进行图像处理如旋转、缩放等操作至关重要。
摘要由CSDN通过智能技术生成

 首先想要了解YUV为何物,请猛戳:https://msdn.microsoft.com/en-us/library/aa904813(VS.80).aspx

上面的链接中,微软已经写的很详细了,国内大部分文章都是翻译这篇文章的,如果还有疑问的同学可以参考下面这些大神的博客:

 

看完上面的文章应该都会有所了解和认识了,因为在Android API <= 20(Android5.0之前的版本)中Google支持的Camera Preview Callback的YUV常用格式有两种:一个是NV21,一个是YV12,在此针对这两种格式做分析。

NV21:

  先贴一段微软的叙述:

4:2:0 Formats, 12 Bits per Pixel

  Four 4:2:0 12-bpp formats are recommended, with the following FOURCC codes:

  • IMC2
  • IMC4
  • YV12
  • NV12

  In all of these formats, the chroma channels are subsampled by a factor of two in both the horizontal and vertical dimensions. 

YV12

  All of the Y samples appear first in memory as an array of unsigned char values. This array is followed immediately by all of the V (Cr) samples. The stride of the V plane is half the stride of the Y plane, and the V plane contains half as many lines as the Y plane. The V plane is followed immediately by all of the U (Cb) samples, with the same stride and number of lines as the V plane (Figure 12).

Figure 12. YV12 memory layout

Figure 12. YV12 memory layout

NV12

  All of the Y samples are found first in memory as an a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值