I am now doing video processing using DM6437.
Now I just want to convert from YUV ( 4:2:2 ) to RGB, but unfortunately , I encountered a problem, the converted result is bellow:
Obviously, there exists a lot of noise.
The code I used are as follows( marked in red ):
First,I extract the YUV components, and put them in the arrays below,
unsigned char YArray[720*480] = {0};
unsigned char CrArray[720*240] = {0};
unsigned char CbArray[720*240] = {0};
then, I invoke the function below,
PIXEL_COLOR *YUV2RGB(unsigned char *Y,unsigned char *Cr,unsigned char *Cb,PIXEL_COLOR *RGB,int width,int height)
{
int i = 0;
int j = 0;
int k = 0;
for( i = 0; i< height;i++)
{
k = i*width;
for(j = 0;j < width;j++)
{
RGB[k+j].r = (298*(Y[k+j]-16) + 409*(Cr[ (k+j) / 2] - 128) + 128) >> 8;
RGB[k+j].g = (298*(Y[k+j]-16) - 208*(Cr[(k+j) / 2] - 128) - 100*(Cb[(k+j) / 2] - 128) + 128) >> 8;
RGB[k+j].b = (298*(Y[k+j]-16) + 516*(Cb[(k+j) / 2] - 128) + 128) >> 8;
if(RGB[k+j].r > 255)
{
RGB[k+j].r = 255;
}
else if(RGB[k+j].r < 0)
{
RGB[k+j].r = 0;
}
if(RGB[k+j].g > 255)
{
RGB[k+j].g = 255;
}
else if(RGB[k+j].g < 0)
{
RGB[k+j].g = 0;
}
if(RGB[k+j].b > 255)
{
RGB[k+j].b = 255;
}
else if(RGB[k+j].b < 0)
{
RGB[k+j].b = 0;
}
}
}
return RGB;
}
finally, I show the image using ccs, the detailed steps are as follows:
View -> Graph -> Image...
Could anyone help me?
Thank you!
Zhiqiang