YVU420PackedSemiPlanar32m4ka与YUV420PackedSemiPlanar64x32Tile2m8ka

来源:互联网 发布:万影数据 编辑:程序博客网 时间:2024/05/28 15:05

YVU420PackedSemiPlanar32m4kaYUV420PackedSemiPlanar64x32Tile2m8ka都是nv12变换来的。



*  YVU420PackedSemiPlanar       : Buffer containing all Y, and then V and U 

 *                                 interleaved.

 *  YVU420PackedSemiPlanar32m4ka : YUV planar format, similar to the 

 *                                 YVU420PackedSemiPlanar format, but with the

 *                                 following restrictions:

 *

 *                                 1. The width and height of both plane must 

 *                                 be a multiple of 32 texels.

 *

 *                                 2. The base address of both planes must be 

 *                                 aligned to a 4kB boundary.

 * 

 *  YUV420PackedSemiPlanar16m2ka : YUV planar format, similar to the

 *                                 YUV420PackedSemiPlanar format, but with the

 *                                 following restrictions:

 *

 *                                 1. The width of the luma plane must be a

 *                                 multiple of 16 pixels.

 *

 *                                 2. The address of both planes must be 

 *                                 aligned to a 2kB boundary.

 * 

 *  YUV420PackedSemiPlanar64x32Tile2m8ka : YUV planar format, similar to the 

 *                                 YUV420PackedSemiPlanar format, but with the

 *                                 following restrictions:

 *

 *                                 1. The data is laid out in a 4x2 MB tiling 

 *                                 memory structure

 *

 *                                 2. The width of each plane is a multiple of

 *                                 2 4x2 MB tiles.

 *

 *                                 3. The height of each plan is a multiple of

 *                                 a 4x2 MB tile.

 *

 *                                 4. The base address of both planes must be 

 *                                 aligned to an 8kB boundary.

 *

 *                                 5. The tiles are scanned in the order 

 *                                 defined in the MFCV5.1 User's Manual.

 */


YUV420PackedSemiPlanar64x32Tile2m8ka其实是V4L2_PIX_FMT_NV12MT(TM12)

子块的内存布局为:


宽度需要与128倍数对齐,若模块竖向分辨率为奇数,则最后一行以线性布局。极限情况布局如下:



下面给出YVU420PackedSemiPlanar32m4kayv12的代码,以480x480为例:


void YUV420PackedSemiPlanar32mToYUV420(char* src,char* dst)

{

    const int width =512;

    const int height =480;

    char* _yuv = dst;

    char* _y = _yuv;

    char* _u = _yuv + width*height;

    char* _v = _u + width*height/4;

    memset(_yuv, 0, width*height*3/2);

    

    memcpy(_y,src,width*height);

    

    char* pStart = src + width*height;

    for (int i=0; i<height*width/4; i++) {

            *_u++ = *pStart++;

            *_v++ = *pStart++;

    }

    

}

0 0