YCbCr422ToRGB
Converts a YCbC422 image to an RGB color model using 4:2:2 sampling. A YCbC422 image uses 4:2:2 sampling, that is, Y is sampled twice, and Cb and Cr are sampled once for every two pixel blocks.
The function interface declaration is as follows:
- Operation on pixel-order data:
HmppResult HMPPI_YCbCr422ToRGB_8u_C2C3R(const uint8_t *src, int32_t srcStep, uint8_t *dst, int32_t dstStep, HmppiSize roiSize);
HmppResult HMPPI_YCbCr422ToRGB_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_YCbCr422ToRGB_8u_C2P3R(const uint8_t *src, int32_t srcStep, uint8_t *dst[3], int32_t dstStep, HmppiSize roiSize);
- Conversion from planar data to pixel-order data:
HmppResult HMPPI_YCbCr422ToRGB_8u_P3C3R(const uint8_t *src[3], int32_t srcStep[3], uint8_t *dst, int32_t dstStep, HmppiSize roiSize);
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 |
aval |
Constant value used to fill the fourth channel |
None |
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 roiSize field is zero or negative. The roiSize width of P3C3R must be greater than 1. |
HMPP_STS_STEP_ERR |
The value of srcStep or dstStep is zero 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 90
#define DST_BUFFER_SIZE_T 120
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
};
uint8_t a[DST_BUFFER_SIZE_T] = { 0 };
uint8_t b[DST_BUFFER_SIZE_T] = { 0 };
uint8_t c[DST_BUFFER_SIZE_T] = { 0 };
uint8_t *dst[3] = {a, b, c};
int32_t srcStep = 12 * sizeof(uint8_t);
int32_t dstStep = 20 * sizeof(uint8_t);
HmppResult result = HMPPI_YCbCr422ToRGB_8u_C2P3R(src, srcStep, dst, dstStep, roi);
printf("result = %d \ndst = ", result);
if (result != HMPP_STS_NO_ERR) {
printf("result error: %d\n", result);
}
for(int32_t i = 0; i < 3; i++){
int32_t dstWidth = dstStep / sizeof(uint8_t);
for (int32_t j = 0; j < DST_BUFFER_SIZE_T; j++) {
if( j % dstWidth == 0 ){
printf("\n");
}
printf("%3d ",dst[i][j]);
}
}
printf("\n");
}
int main()
{
TestExample();
return 0;
}
Output:
result = 0 dst = 0 0 0 7 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 7 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 103 129 102 127 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 173 147 103 129 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 163 137 155 117 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 119 55 163 137 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0