大手给看看这个用r0 = 1402*(cr0-128)/1000+y0;g0 = (- 344*(cb0-128) - 714*(cr0-128))/1000+y0;b0 = 1772*(cb0-128)/1000+y0;转换完得到的实时图像,这是什么原因引起的?
------最佳解决方案--------------------
=(1<<11);
rgb_data0 = 0;
#endif
#if CAM_CODEC_OUTPUT==CAM_CCIR420
for (y=0;y<size_y;y++) // YCbCr 4:2:0 format
{
for (x=0;x<size_x;x+=2)
{
rgb_data0 = Conv_YCbCr_Rgb(*buffer_y++, *buffer_y++, *buffer_cb++, *buffer_cr++);
LCD_BUFFER_CAM[y][x/2] = rgb_data0;
}
}
#else
// for (y=0;y<size_y;y+=2) // YCbCr 4:2:2 format
for (y=0;y<size_y;y++) // YCbCr 4:2:2 format
{
// for (x=0;x<size_x;x+=2)
for (x=0;x<size_x;x++)
{
// U16 lt;
// Uart_Printf("\n x %d y %d " ,x,y);
// Uart_Printf("\ny0 %x cb %x cr %x " ,buffer_y,buffer_cb,buffer_cr);
// rgb_data1 = Conv_YCbCr_Rgb(*buffer_y++, *buffer_y++, *buffer_cb++, *buffer_cr++); //2012-11-06
// rgb_data0 = Conv_YCbCr_Rgb(*buffer_y++, *buffer_y++, *buffer_cb++, *buffer_cr++);
rgb_data0 = Conv_YCbCr_Rgb(*buffer_y, *(buffer_y+1), *buffer_cb, *buffer_cr);
buffer_y++;
if(x%2){
buffer_cb++;
buffer_cr++;
}
LCD_BUFFER_CAM[y][x] = rgb_data0; //2012-11-01
// LCD_BUFFER_CAM[y+1][x+1] = rgb_data1;
// LCD_BUFFER_CAM[y][x/2+1] = rgb_data0>>16;
}
}
U32 Conv_YCbCr_Rgb(U8 y0, U8 y1, U8 cb0, U8 cr0)
{
int r0, g0, b0;
U32 rgb0;
r0 = (1000*y0 + 1371*(cr0-128))/1000;
g0 = (1000*y0 - 336*(cb0-128) - 714*(cr0-128))/1000;
b0 = (1000*y0 + 1732*(cb0-128))/1000;
#endif
if (r0>255 ) r0 = 255;
if (r0<0) r0 = 0;
if (g0>255 ) g0 = 255;
if (g0<0) g0 = 0;
if (b0>255 ) b0 = 255;
if (b0<0) b0 = 0;
rgb0 = (((U16)r0>>3)<<11)
------其他解决方案--------------------
(((U16)g0>>2)<<5)
------其他解决方案--------------------
1.yuv有n多种格式
采样: 4:4:4 4:2:2 4:2:0 4:1:1
排列:YVYU UYVY YV12 打包 等务必确定原始的数组是什么样的格式
yuv色彩空间: https://zh.wikipedia.org/zh/YUV
2.rbg 也有N多种 ;24位 16色 32色 等