Rate This Document
Findability
Accuracy
Completeness
Readability

YCbCrI420ToRGB24

Converts a YCbCrI image to the RGB or BGR format. The formulas are as follows:

,

,

,

,

,

. clamp indicates that the value is limited within [0, 255].

The function interface declaration is as follows:

  • Conversion from YCbCrI420 to RGB24:

    HmppResult HMPPI_YCbCrI420ToRGB24_8u(const uint8_t *src, uint8_t *dst, int32_t width, int32_t height);

  • Conversion from YCbCrI420 to BGR24:

    HmppResult HMPPI_YCbCrI420ToBGR24_8u(const uint8_t *src, uint8_t *dst, int32_t width, int32_t height);

Parameters

Parameter

Description

Value Range

Input/Output

src

Pointer to the source vector

The value cannot be NULL.

Input

dst

Pointer to the destination vector

The value cannot be NULL.

Output

width

Image width (in pixels)

(0, INT_MAX]. The value is an integer multiple of 2.

Input

height

Image height (in pixels)

(0, INT_MAX]. The value is an integer multiple of 2.

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 width or height is less than or equal to 0.

HMPP_STS_DOUBLE_SIZE_ERR

The value of width or height is not a multiple of 2.

Example

#define SRC_BUFFER_SIZE_T 6
#define DST_BUFFER_SIZE_T 12

int YcbcrToRgbExample(){
    int32_t i;
    uint8_t dst[DST_BUFFER_SIZE_T] = {0};
    uint8_t src[SRC_BUFFER_SIZE_T] = {0, 255, 5, 34, 122, 78};
    HmppResult result = HMPPI_YCbCrI420ToRGB24_8u(src, dst, 2, 2);
    printf("result = %d \ndst =", result);
    for (i = 0; i < DST_BUFFER_SIZE_T; i++) {
        printf(" %d  ", dst[i]);
    }
    return 0;
}

Output:

result = 0
dst = 0   24   0   199   255   255   0   30   0   0   64   9