Rate This Document
Findability
Accuracy
Completeness
Readability

YCbCr422ToBGR

Converts a YCbCr image in 4:2:2 sampling format to a BGR image. 4:2:2 YCbCr 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_YCbCr422ToBGR_8u_C2C3R(const uint8_t* src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize)

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

  • Conversion from planar data to pixel-order data:

    HmppResult HMPPI_YCbCr422ToBGR_8u_P3C3R(const uint8_t* src[0x3], int32_t srcStep[0x3], uint8_t *dst, 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 ∈ (2, 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 zero or negative, or the value of roiSize.width is less than 2.

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_NO_ERR

No error occurs.

Example

#define SRC_BUFFER_SIZE_T 48
#define DST_BUFFER_SIZE_T 60
void TestExample()
{
    HmppiSize roi = { 4, 4 };
    const uint8_t srcY[SRC_BUFFER_SIZE_T] = {
        11, 22, 33, 44, 55, 66, 77, 88, 22, 88, 77, 66,
        55, 44, 33, 11, 22, 33, 44, 55, 66, 77, 88, 22,
        88, 77, 66, 55, 44, 33, 11, 22, 33, 44, 55, 66,
        77, 88, 22, 88, 77, 66, 55, 44, 33, 11, 22, 33
    };

    const uint8_t srcCb[SRC_BUFFER_SIZE_T] = {
        177, 188, 122, 188, 177, 166, 155, 144,
        155, 144, 133, 111, 122, 133, 144, 155,
        188, 177, 166, 155, 144, 133, 111, 122,
        111, 122, 133, 144, 155, 166, 177, 188
    };

    const uint8_t srcCr[SRC_BUFFER_SIZE_T] = {
        255, 244, 233, 111, 212, 233, 244, 255,
        188, 177, 166, 255, 144, 233, 121, 122,
        177, 188, 222, 188, 177, 166, 155, 144,
        211, 222, 233, 244, 155, 166, 177, 188
    };

    const uint8_t *src[3] = {srcY, srcCb, srcCr};
    int32_t srcStep[3] = {12, 8, 8};
    uint8_t dst[DST_BUFFER_SIZE_T] = { 0 };
    int32_t dstStep = 12 * sizeof(uint8_t);

    HmppResult result = HMPPI_YCbCr422ToBGR_8u_P3C3R(src, srcStep, dst, dstStep, roi);
    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 = 
 93   0 196 105   0 209 140   0 204 153   0 217 
 99   0 141  87   0 128  52   0  97  26   0  72 
204  20 162 192   7 149 157   0 153 144   0 141 
 36  10 203  49  22 216   0   0 157  71   9 233 
  0   0   0   0   0   0   0   0   0   0   0   0