Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 10/31/2024
Public
Document Table of Contents

YCrCb420ToRGB, YCrCb420ToBGR

Convert a YCrCb image with the 4:2:0 sampling to the RGB or BGR image.

Syntax

IppStatus ippiYCrCb420ToRGB_8u_P3C4R (const Ipp8u* pSrc[3],int srcStep[3], Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp8u aval);

IppStatus ippiYCrCb420ToRGB_8u_P2C4R (const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCrCb, int srcCrCbStep, Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp8u aval);

IppStatus ippiYCrCb420ToRGB_8u_P2C3R (const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCrCb, int srcCrCbStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);

IppStatus ippiYCrCb420ToBGR_8u_P2C3R (const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCrCb, int srcCrCbStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);

IppStatus ippiYCrCb420ToBGR_8u_P2C4R (const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCrCb, int srcCrCbStep, Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp8u aval);

IppStatus ippiYCrCb420ToBGR_Filter_8u_P3C4R (const Ipp8u* pSrc[3], int srcStep[3], Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp8u aval);

Include Files

ippcc.h

Domain Dependencies

Headers: ippcore.h, ippvm.h, ipps.h, ippi.h

Libraries: ippcore.lib, ippvm.lib, ipps.lib, ippi.lib

Parameters

pSrc

An array of pointers to ROI in separate planes of the three-plane source image.

srcStep

An array of distances, in bytes, between the starting points of consecutive lines in each plane of the three-plane source image.

pSrcY

Pointer to ROI in the luminance plane of the two-plane source image.

srcYStep

Distance, in bytes, between the starting points of consecutive lines in the luminance plane of the two-plane source image.

pSrcCrCb

Pointer to ROI in the interleaved plane chrominance plane of the two-plane source image.

srcCrCbStep

Distance, in bytes, between the starting points of consecutive lines in the interleaved chrominance plane of the two-plane source image.

pDst

Pointer to the destination image ROI.

dstStep

Distance, in bytes, between the starting points of consecutive lines in the destination image.

roiSize

Size of the source and destination ROI, in pixels.

aval

Constant value to create the fourth channel.

Description

This function operates with ROI.

This function converts the Y'Cr'Cb' image pSrc to the gamma-corrected R'G'B' or B'G'R' image pDst according to the same formulas as the ippiippiYCbCrToRGB function does. The difference is that the ippiYCrCb420ToRGB and ippiYCrCb420ToBGR functions use the source data in the 4:2:0 sampling format, in which the number of Cb and Cr samples is reduced by half in both vertical and horizontal directions (see Table “Planar Image Formats” for more details). Two-plane Y'Cr'Cb image with 4:2:0 sampling is also known as NV21 format.

The value of roiSize.width and roiSize.height must be a multiple of 2. Otherwise, the function reduces original values of roiSize.width and roiSize.height to the nearest multiples of 2, performs operation, and returns a warning.

Return Values

ippStsNoErr

Indicates no error. Any other value indicates an error or a warning.

ippStsNullPtrErr

Indicates an error when pSrc or pDst is NULL.

ippStsSizeErr

Indicates an error when roiSize has a field with a value less than 2.

ippStsDoubleSize

Indicates a warning if roiSize has a field that is not a multiple of 2.

Example

The code example below demonstrates how to use the ippiYCrCb420ToRGB_8u_P2C4R function.

static void sampleNV21ToRGBA()
{
    Ipp8u pY[4*4]=
    {
        236,236,236,236,
        236,236,236,236,
        236,236,236,236,
        236,236,236,236
    };
    Ipp8u pCbCr[4*2]=
    {
        128,128,128,128,
        128,128,128,128
    };
    Ipp8u pRGB[(4*4)*4];
    int YStep = 4, CbCrStep = 4, rgbStep  = 4*4;
    IppiSize roiSize = {4,4};
    Ipp8u alpha = 0xFF;
    IppStatus status = ippiYCrCb420ToRGB_8u_P2C4R(pY, YStep, pCbCr, CbCrStep, pRGB, rgbStep, roiSize, alpha);
    if ( status == ippStsNoErr) 
        printf("\n *************  passed ****************\n");
    else 
        printf("\n *************  failed ****************\t"); 
}