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

ID 790148
Date 3/22/2024
Public
Document Table of Contents

YCbCr420ToRGB, YCbCr420ToBGR

Convert a YCbCr image that has 4:2:0 sampling format to the RGB or BGR color model.

Syntax

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

IppStatus ippiYCbCr420ToRGB_8u_P2C3R(const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCbCr, int srcCbCrStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);

IppStatus ippiYCbCr420ToRGB_8u_P2C4R(const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCbCr, int srcCbCrStep, Ipp8u* pDst, int dstStep, IppiSize roiSize, Ipp8u aval);

IppStatus ippiYCbCr420ToBGR_8u_P2C3R(const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCbCr, int srcCbCrStep, Ipp8u* pDst, int dstStep, IppiSize roiSize);

IppStatus ippiYCbCr420ToBGR_8u_P2C4R(const Ipp8u* pSrcY, int srcYStep, const Ipp8u* pSrcCbCr, int srcCbCrStep, 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 starts 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 starts of consecutive lines in the luminance plane of the two-plane source image.

pSrcCbCr

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

srcCbCrStep

Distance in bytes between starts 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 starts 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 (see Regions of Interest in Intel IPP).

This function converts the Y'Cb'Cr' image pSrc to the gamma-corrected R'G'B' or B'G'R' image pDst according to the same formulas as the function ippiYCbCrToRGB does. The difference is that the ippiYCbCr420ToRGB and ippiYCbCr420ToBGR functions use the input 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'Cb'Cr' image with 4:2:0 sampling is also known as NV12 format.

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

Return Values

ippStsNoErr

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

ippStsNullPtrErr

Indicates an error condition if pSrc or pDst is NULL.

ippStsSizeErr

Indicates an error condition if roiSize has a field with 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 ippiYCbCr420ToRGB_8u_P2C4R function.

    #define WIDTH 4
    #define HEIGHT 4

    Ipp8u pSrcY[WIDTH * HEIGHT] =
    {
        236,236,236,236,
        236,236,236,236,
        236,236,236,236,
        236,236,236,236
    };
    Ipp8u pSrcCbCr[WIDTH * HEIGHT / 2] =
    {
        128,128,128,128,
        128,128,128,128
    };
    Ipp8u pDstRGB[(WIDTH * HEIGHT) * 4];
    int srcYStep = WIDTH, srcCbCrStep = WIDTH, dstStep  = WIDTH * 4;
    IppiSize roiSize = {WIDTH, HEIGHT};
    Ipp8u alphaValue = 0xFF;
    IppStatus status = ippiYCbCr420ToRGB_8u_P2C4R(pSrcY, srcYStep, pSrcCbCr, srcCbCrStep, pDstRGB, dstStep, roiSize, alphaValue);
    if ( status == ippStsNoErr) 
        printf("\n *************  passed ****************\n");
    else 
        printf("\n *************  failed ****************\n");