首先想要了解YUV为何物,请猛戳:https://msdn.microsoft.com/en-us/library/aa904813(VS.80).aspx
上面的链接中,微软已经写的很详细了,国内大部分文章都是翻译这篇文章的,如果还有疑问的同学可以参考下面这些大神的博客:
- 最简单的基于FFmpeg的libswscale的示例(YUV转RGB) http://blog.youkuaiyun.com/leixiaohua1020/article/details/42134965
- 图文详解YUV420数据格式:http://www.cnblogs.com/azraelly/archive/2013/01/01/2841269.htm
- ANDROID 高性能图形处理: http://tangzm.com/blog/?p=1
看完上面的文章应该都会有所了解和认识了,因为在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
NV12
All of the Y samples are found first

本文详细介绍了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值。了解这些格式对于进行图像处理如旋转、缩放等操作至关重要。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



