yuv 格式之 Semi Planar和Planar
YUV 格式通常有兩大類:打包(packed)格式和平面(planar)格式。前者將 YUV 分量存放在同一個陣列中,
通常是幾個相鄰的畫素組成一個巨集畫素(macro-pixel);而後者使用三個陣列分開存放 YUV 三個分量,就像
是一個三維平面一樣。
幾種常見的yuv格式
1.YUV422 Planar
這裡,Y\U\V資料是分開存放的,每兩個水平Y取樣點,有一個Cb和一個Cr取樣點,如下圖
ffmpeg 中的定義 PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Android OMX 中的定義 OMX_COLOR_FormatYUV422Planar //* YUV422Planar : Three arrays Y,U,V.
2. YUV420 Planar
這個格式跟YUV422 Planar 類似,但對於Cb和Cr的取樣在水平和垂直方向都減少為2:1,如下圖
ffmpeg 中定義 PIX_FMT_YUV420P //< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
android OMX 中定義 OMX_COLOR_FormatYUV420Planar // * YUV420Planar : Three arrays Y,U,V
3.YUV422 Semi-Planar
Semi 是’半‘的意思 我的理解這個半平面模式,這個格式的資料量跟YUV422 Planar的一樣,但是U、V是交叉存放的,如下圖。
ffmpeg 中 未找到定義
android OMX 中 OMX_COLOR_FormatYUV422SemiPlanar ////YUV422SemiPlanar : Two arrays, one is all Y, the other is U and V
4.YUV420 Semi-Planar
這個格式的資料量跟YUV420 Planar的一樣,但是U、V是交叉存放的,如下圖。
ffmpeg 中定義
PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
android OMX 中定義 OMX_COLOR_FormatYUV420SemiPlanar //YUV420SemiPlanar : Two arrays, one is all Y, the other is U and V
5.YUV422 Interleaved Interleaved -- 交錯
這個格式的資料量跟YUV422 Planar的一樣,但是Y、U、V是交叉存放的,如下圖。 這個是打包(packed)模式的
ffmpeg 中 PIX_FMT_UYVY422 ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
android OMX 中 OMX_COLOR_FormatCbYCrY //CbYCrY : Organized as 16bit UYVY (i.e. CbYCrY)