YUV422ToRGB
Converts a YUV422 image to an RGB color model using 4:2:2 sampling. A YUV422 image uses 4:2:2 sampling, that is, Y is sampled twice, and U and V are sampled once for every two pixel blocks.
The function interface declaration is as follows:
- Operation on pixel-order data:
HmppResult HMPPI_YUV422ToRGB_8u_C2C3R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize);
- Operation on planar data:
HmppResult HMPPI_YUV422ToRGB_8u_P3R(const uint8_t *src[3], int32_t srcStep[3], uint8_t *dst[3], int32_t dstStep, HmppiSize roiSize);
- Operation on planar data (without ROI):
HmppResult HMPPI_YUV422ToRGB_8u_P3(const uint8_t *src[3], uint8_t *dst[3], HmppiSize imgSize);
- Conversion from planar data to pixel-order data:
HmppResult HMPPI_YUV422ToRGB_8u_P3AC4R(const uint8_t *src[3], int32_t srcStep[3], uint8_t *dst, int32_t dstStep, HmppiSize roiSize);
HmppResult HMPPI_YUV422ToRGB_8u_P3C3R(const uint8_t *src[3], int32_t srcStep[3], uint8_t *dst, int32_t dstStep, HmppiSize roiSize);
- Conversion from planar data to pixel-order data (without ROI):
HmppResult HMPPI_YUV422ToRGB_8u_P3C3(const uint8_t *src[3], uint8_t *dst, HmppiSize imgSize);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the source buffer of pixel-order data. If the input is planar data, this parameter indicates an array of pointers to separate source color planes. |
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 buffer of pixel-order data. If the input is planar data, this parameter indicates an array of pointers to separate destination color planes. |
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 |
imgSize |
Size of the source and target images, in pixels |
imgSize.width ∈ (0, INT_MAX], imgSize.height ∈ (0, INT_MAX] |
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_NO_ERR |
No error occurs. |
Example
#define SRC_BUFFER_SIZE_T 96
#define DST_BUFFER_SIZE_T 144
void TestExample()
{
HmppiSize roi = { 4, 4 };
const uint8_t src[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, 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, 44, 55, 66
};
uint8_t dst[DST_BUFFER_SIZE_T] = { 0 };
int32_t srcStep = 12 * sizeof(uint8_t);
int32_t dstStep = 18 * sizeof(uint8_t);
HmppResult result = HMPPI_YUV422ToRGB_8u_C2C3R(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 = 0 102 0 0 124 0 9 103 0 31 125 0 0 0 0 0 0 0 0 156 0 0 134 0 0 102 0 0 124 0 0 0 0 0 0 0 5 151 0 0 129 0 0 143 0 0 110 0 0 0 0 0 0 0 31 116 0 0 61 0 0 150 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0