Rate This Document
Findability
Accuracy
Completeness
Readability

YCrCb422ToRGB

Converts a YCrCb image in 4:2:2 sampling format to an RGB image. 4:2:2 YCrCb sampling indicates that Y is sampled twice, and Cb and Cr are sampled once for every two pixel blocks.

This function converts the color according to the following formulas:

The function interface declaration is as follows:

  • Operation on pixel-order data:

    HmppResult HMPPI_YCrCb422ToRGB_8u_C2C3R(const uint8_t* src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize);

    HmppResult HMPPI_YCrCb422ToRGB_8u_C2C4R(const uint8_t* src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize, uint8_t aVal);

  • Conversion from pixel-order to planar data:

    HmppResult HMPPI_YCrCb422ToRGB_8u_C2P3R(const uint8_t* src, int32_t srcStep, uint8_t *dst[0x3], int32_t dstStep, HmppiSize roiSize);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source image. This array stores the color data of the source planar image.

The value cannot be NULL.

Input

srcStep

Distance between starts of consecutive lines in the source image, in bytes

The value must be zero or a positive integer.

Input

dst

Pointer to the destination image ROI. This array stores the color data of the destination planar image.

The value cannot be NULL.

Output

dstStep

Distance between starts of consecutive lines in the destination image, in bytes

The value must be zero or a positive integer.

Input

roiSize

Size of the ROI of the source and destination images, in pixels

roiSize.width ∈ (0, INT_MAX], roiSize.height ∈ (0, INT_MAX]

Input

aVal

Constant value used to fill the fourth channel

The value must be zero or a positive integer.

Input

Return Value

  • Success: HMPP_STS_NO_ERR
  • Failure: An error code is returned.

Error Codes

Error Code

Description

HMPP_STS_NULL_PTR_ERR

The value of src or dst is NULL.

HMPP_STS_SIZE_ERR

The value of roiSize is 0 or negative.

HMPP_STS_STEP_ERR

The value of srcStep or dstStep is 0 or negative.

HMPP_STS_ROI_ERR

roiSize.width x Number of channels x Number of bytes occupied by the data type > Step

HMPP_STS_DOUBLE_SIZE

The value of roiSize.width is an odd number. (This is a warning code and does not affect the proper execution of the function.)

HMPP_STS_NO_ERR

No error occurs.

Example

#define SRC_BUFFER_SIZE_T 64
#define DST_BUFFER_SIZE_T 64
void TestExample()
{
    HmppiSize roi = { 4, 4 };
    const uint8_t src[SRC_BUFFER_SIZE_T] = {
        121, 212, 131, 255, 11, 22, 33, 44, 55, 66, 42, 10,
        156, 93,  243, 200, 55, 44, 33, 11, 22, 33, 30, 99,
        4,   233, 109, 27,  88, 77, 66, 55, 44, 33, 5,  22,
        6,   7,   8,   0,   77, 88, 22, 88, 77, 66, 1,   0,
        44,  33,  22,  11,  55, 66, 77, 88, 99, 10, 59, 32
    };

    int32_t srcStep = 12 * sizeof(uint8_t);
    uint8_t dst[DST_BUFFER_SIZE_T] = { 0 };
    int32_t dstStep = 16 * sizeof(uint8_t);
    uint8_t aVal = 0x40;

    HmppResult result = HMPPI_YCrCb422ToRGB_8u_C2C4R(src, srcStep, dst, dstStep, roi, aVal);
    printf("result = %d \ndst = ", result);
    if (result != HMPP_STS_NO_ERR) {
        printf("result error: %d\n", result);
    }
    int32_t dstWidth = dstStep / sizeof(uint8_t);
    for (int32_t i = 0; i < DST_BUFFER_SIZE_T; i++) {
        if( i % dstWidth == 0 ){
            printf("\n");
        }
        printf("%3d ",dst[i]);
    }
    printf("\n");
}

int main()
{
   TestExample();
   return 0;
}

Output:

result = 0 
dst = 
255   4 255  64 255  16 255  64   0 113   0  64   0 139   0  64 
107 163 255  64 208 255 255  64   0 160   0  64   0 134   0  64 
154   0   0  64 255  62   0  64   2 154   0  64   0 128   0  64 
  0 137   0  64   0 139   0  64   7 119   0  64   0  55   0  64