YUV TO RGB
void NV21_T_RGB( unsigned char *yuyv , unsigned char *rgb,unsigned int width , unsigned int height )
{
const int nv_start = width * height ;
HI_U32 i, j, index = 0, rgb_index = 0;
HI_U8 y, u, v;
int r, g, b, nv_index = 0;
for(i = 0; i < height ; i++)
{
for(j = 0; j < width; j ++){
//nv_index = (rgb_index / 2 - width / 2 * ((i + 1) / 2)) * 2;
nv_index = i / 2 * width + j - j % 2;
y = yuyv[rgb_index];
v = yuyv[nv_start + nv_index ];
u = yuyv[nv_start + nv_index + 1];
r = y + (140 * (v-128))/100; //r
g = y - (34 * (u-128))/100 - (71 * (v-128))/100; //g
b = y + (177 * (u-128))/100; //b
if(r > 255) r = 255;
if(g > 255) g = 255;
if(b > 255) b = 255;
if(r < 0) r = 0;
if(g < 0) g = 0;
if(b < 0) b = 0;
index = j + i * width;
//bgr planner排列
//rgb[index] = b;
//rgb[index+nv_start] = g;
//rgb[index+2*nv_start] = r;
//bgr排列
rgb[index * 3+0] = b;
rgb[index * 3+1] = g;
rgb[index * 3+2] = r;
rgb_index++;
}
}
}