Convert YUV420 Planar to YUV422 Packed
There are usually two main categories of YUV formats: the packed format and the planar format.
Packed format stores YUV components in the same array, usually with several adjacent pixels forming a macropixel (macro-pixel).
For example, two adjacent pixels form a macro pixel, UYVY
The Planar format uses three arrays to store the three components of YUV separately.
After decoding the H.264 bitstream using the FFMPEG avcodec_decode_video () function, the YUV component stored in planar format is obtained.
Data [0], linesize [0], describe the address and span of the Y component (stride)
Data [1], data [2], linesize [1], describe the address and span of the UMagee V component (stride)
In some cases, we need to convert YUV420 Planar format to YUV422 Packed format for easy display or processing. The following function uses the MMX instruction to accomplish this task.
Void YUV420toUYVY422 (unsigned char * pszSrcY, int iSrcPitchY, unsigned char * pszSrcU
Unsigned char * pszSrcV, int iSrcPitchUV, unsigned char * pszDst
Int iSrcWidth, int iSrcHeight, int iDstPitch)
{
Int iSrcStride = iSrcPitchY + iSrcPitchY-iSrcWidth
Int iSrcStrideU = (iSrcPitchY-iSrcWidth) > > 1
Int iDstStride = (iDstPitch-iSrcWidth)