Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

'UYVY' 4:2:2 Pixel Format to YUV420 Planar

juriev
Beginner
1,483 Views

Hi

I have the following Pixel Format 'UYVY'4:2:2 Compression interleaved. In the document it is described as the following
Four 8-bit Unsigned Components are packed into one 32-bit little-endian word.
Byte_3:Y'1 Byte_2:Cr0 Byte_1:Y'0 Byte_0:Cb0.

I want to convert this into YUV420 Planar or somethingI can use with mpeg2 compression.
What functions is there availablein IPP to achieve this as it is very confusing.

Jurie

0 Kudos
1 Solution
Vladimir_Dudnik
Employee
1,483 Views
Do you have any problem to look at IPP documentation or header files?

I think something from the follwong should do what you are looking for:

[cpp]/* ////////////////////////////////////////////////////////////////////////////
//  Name:       ippiYUToYU422_8u_C2P2R, ippiUYToYU422_8u_C2P2R
//  Purpose:    Converts 2-channel YUY2,UYVY images to the 2-plane NV12 image
//
//  Return:
//    ippStsNoErr              Ok
//    ippStsNullPtrErr         One of the pointers is NULL
//    ippStsSizeErr            roiSize has a field value less than 2
//
//  Parameters:
//    pDstY                    Pointer to the destination image Y plane.
//    dstYStep                 The step through the destination image Y plane.
//    pDstCbCr                 Pointer to the destination image CbCr plane.
//    dstCbCrStep              The step through the destination image CbCr plane.
//    pSrc                     Pointer to the source image
//    srcStep                  Step through the source image
//    roiSize                  Size of the ROI, should be multiple of 2.
//  Notes:
//    for ippiYUToYU422_8u_C2P2R sequence of bytes in the source image is( YUY2 ):
//                   Y0U0Y1V0,Y2U1Y3V1,...
//    for ippiUYToYU422_8u_C2P2R sequence of bytes in the destination image is( UYVY ):
//                   U0Y0V0Y1,U1Y2V1Y3,...
//    Sequence of bytes in the destination image is( NV12 ):
//        Y plane    Y0Y1Y2Y3
//       UV plane    U0V0U1V1
*/

IPPAPI(IppStatus, ippiYCbCr422ToYCbCr420_8u_C2P2R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDstY, int dstYStep,Ipp8u* pDstCbCr,int dstCbCrStep, IppiSize roiSize ))
IPPAPI(IppStatus, ippiCbYCr422ToYCbCr420_8u_C2P2R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDstY, int dstYStep,Ipp8u* pDstCbCr,int dstCbCrStep, IppiSize roiSize ))

/* ////////////////////////////////////////////////////////////////////////////
//  Name:       ippiYCbCr422ToYCrCb420_8u_C2P3R, ippiCbYCr422ToYCrCb420_8u_C2P3R
//  Purpose:    Converts 2-channel YUY2,UYVY images to the 3-plane YV12 image
//
//  Return:
//    ippStsNoErr              Ok
//    ippStsNullPtrErr         One of the pointers is NULL
//    ippStsSizeErr            roiSize has a field value less than 2
//
//  Parameters:
//    pSrc          Pointer to the source image
//    srcStep       Step through the source image
//    roiSize       Size of the ROI, should be multiple of 2.
//    pDst          An array of pointers  to separate destination color planes.
//    dstStep       An array of step in bytes through the destination planes
//  Notes:
//    for ippiYUToYV422_8u_C2P3R sequence of bytes in the source image is( YUY2 ):
//                   Y0U0Y1V0,Y2U1Y3V1,...
//    for ippiUYToYV422_8u_C2P3R sequence of bytes in the destination image is( UYVY ):
//                   U0Y0V0Y1,U1Y2V1Y3,...
//    Sequence of planes in the destination image is( YV12 ):  Y V U
*/
IPPAPI(IppStatus, ippiYCbCr422ToYCrCb420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],int dstStep[3], IppiSize roiSize ))
IPPAPI(IppStatus, ippiCbYCr422ToYCrCb420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],int dstStep[3], IppiSize roiSize ))

/* ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Name:       ippiYCbCr422ToYCbCr420_8u_C2P3R
//  Purpose:    Converts a 2-channel YUY2 image to the I420(IYUV) image
//  Name:       ippiCbYCr422ToYCbCr420_8u_C2P3R
//  Purpose:    Converts a 2-channel YUY2 image to the I420(IYUV) image
//  Name:       ippiYCrCb422ToYCbCr420_8u_C2P3R
//  Purpose:    Converts a 2-channel YVYU image to the I420(IYUV) image
//  Return:
//    ippStsNoErr              Ok
//    ippStsNullPtrErr         One or more pointers are NULL
//    ippStsSizeErr            if roiSize.width < 2 || roiSize.height < 2
//
//  Arguments:
//    pSrc                     pointer to the source image
//    srcStep                  step for the source image
//    pDst                     array of pointers to the components of the destination image
//    dstStep                  array of steps values for every component
//     roiSize                 region of interest to be processed, in pixels
//  Notes:
//    roiSize.width and roiSize.height  should be multiple 2.
*/
IPPAPI(IppStatus, ippiYCbCr422ToYCbCr420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],
        int dstStep[3], IppiSize roiSize ))
IPPAPI(IppStatus, ippiCbYCr422ToYCbCr420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],
        int dstStep[3], IppiSize roiSize ))
IPPAPI(IppStatus, ippiYCrCb422ToYCbCr420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],
        int dstStep[3], IppiSize roiSize ))
[/cpp]


Regards,
Vladimir

View solution in original post

0 Kudos
2 Replies
Vladimir_Dudnik
Employee
1,484 Views
Do you have any problem to look at IPP documentation or header files?

I think something from the follwong should do what you are looking for:

[cpp]/* ////////////////////////////////////////////////////////////////////////////
//  Name:       ippiYUToYU422_8u_C2P2R, ippiUYToYU422_8u_C2P2R
//  Purpose:    Converts 2-channel YUY2,UYVY images to the 2-plane NV12 image
//
//  Return:
//    ippStsNoErr              Ok
//    ippStsNullPtrErr         One of the pointers is NULL
//    ippStsSizeErr            roiSize has a field value less than 2
//
//  Parameters:
//    pDstY                    Pointer to the destination image Y plane.
//    dstYStep                 The step through the destination image Y plane.
//    pDstCbCr                 Pointer to the destination image CbCr plane.
//    dstCbCrStep              The step through the destination image CbCr plane.
//    pSrc                     Pointer to the source image
//    srcStep                  Step through the source image
//    roiSize                  Size of the ROI, should be multiple of 2.
//  Notes:
//    for ippiYUToYU422_8u_C2P2R sequence of bytes in the source image is( YUY2 ):
//                   Y0U0Y1V0,Y2U1Y3V1,...
//    for ippiUYToYU422_8u_C2P2R sequence of bytes in the destination image is( UYVY ):
//                   U0Y0V0Y1,U1Y2V1Y3,...
//    Sequence of bytes in the destination image is( NV12 ):
//        Y plane    Y0Y1Y2Y3
//       UV plane    U0V0U1V1
*/

IPPAPI(IppStatus, ippiYCbCr422ToYCbCr420_8u_C2P2R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDstY, int dstYStep,Ipp8u* pDstCbCr,int dstCbCrStep, IppiSize roiSize ))
IPPAPI(IppStatus, ippiCbYCr422ToYCbCr420_8u_C2P2R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDstY, int dstYStep,Ipp8u* pDstCbCr,int dstCbCrStep, IppiSize roiSize ))

/* ////////////////////////////////////////////////////////////////////////////
//  Name:       ippiYCbCr422ToYCrCb420_8u_C2P3R, ippiCbYCr422ToYCrCb420_8u_C2P3R
//  Purpose:    Converts 2-channel YUY2,UYVY images to the 3-plane YV12 image
//
//  Return:
//    ippStsNoErr              Ok
//    ippStsNullPtrErr         One of the pointers is NULL
//    ippStsSizeErr            roiSize has a field value less than 2
//
//  Parameters:
//    pSrc          Pointer to the source image
//    srcStep       Step through the source image
//    roiSize       Size of the ROI, should be multiple of 2.
//    pDst          An array of pointers  to separate destination color planes.
//    dstStep       An array of step in bytes through the destination planes
//  Notes:
//    for ippiYUToYV422_8u_C2P3R sequence of bytes in the source image is( YUY2 ):
//                   Y0U0Y1V0,Y2U1Y3V1,...
//    for ippiUYToYV422_8u_C2P3R sequence of bytes in the destination image is( UYVY ):
//                   U0Y0V0Y1,U1Y2V1Y3,...
//    Sequence of planes in the destination image is( YV12 ):  Y V U
*/
IPPAPI(IppStatus, ippiYCbCr422ToYCrCb420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],int dstStep[3], IppiSize roiSize ))
IPPAPI(IppStatus, ippiCbYCr422ToYCrCb420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],int dstStep[3], IppiSize roiSize ))

/* ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Name:       ippiYCbCr422ToYCbCr420_8u_C2P3R
//  Purpose:    Converts a 2-channel YUY2 image to the I420(IYUV) image
//  Name:       ippiCbYCr422ToYCbCr420_8u_C2P3R
//  Purpose:    Converts a 2-channel YUY2 image to the I420(IYUV) image
//  Name:       ippiYCrCb422ToYCbCr420_8u_C2P3R
//  Purpose:    Converts a 2-channel YVYU image to the I420(IYUV) image
//  Return:
//    ippStsNoErr              Ok
//    ippStsNullPtrErr         One or more pointers are NULL
//    ippStsSizeErr            if roiSize.width < 2 || roiSize.height < 2
//
//  Arguments:
//    pSrc                     pointer to the source image
//    srcStep                  step for the source image
//    pDst                     array of pointers to the components of the destination image
//    dstStep                  array of steps values for every component
//     roiSize                 region of interest to be processed, in pixels
//  Notes:
//    roiSize.width and roiSize.height  should be multiple 2.
*/
IPPAPI(IppStatus, ippiYCbCr422ToYCbCr420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],
        int dstStep[3], IppiSize roiSize ))
IPPAPI(IppStatus, ippiCbYCr422ToYCbCr420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],
        int dstStep[3], IppiSize roiSize ))
IPPAPI(IppStatus, ippiYCrCb422ToYCbCr420_8u_C2P3R,( const Ipp8u* pSrc, int srcStep, Ipp8u* pDst[3],
        int dstStep[3], IppiSize roiSize ))
[/cpp]


Regards,
Vladimir
0 Kudos
juriev
Beginner
1,483 Views

thanks did solve my problems.
No problem reading it understanding it was the problem but i am sorted now thanks.

jurie
0 Kudos
Reply