miércoles, 7 de noviembre de 2012

dm6437 Convertir YUV422 a RGB888

Int16 MedianFilter_test( )
{
        int height = 480;
int width = 720;
        tvp5150_init();    
    vpfe_init( 0x82000000, 720, 480);
_wait(3000000);
        VPFE_CCDC_PCR=0x0000000; 


for(i = 0; i < height; i++)
{
k = width*i*2;
l = width*i*2;

for(j = 0; j < width/2; j++)
{


cb = *((Uint8*)0x82000000 + 2 + 4*j + k);
y0 = *((Uint8*)0x82000000 + 1 + 4*j + k);
y1 = *((Uint8*)0x82000000 + 3 + 4*j + k);
cr = *((Uint8*)0x82000000 +  4*j + k);

r0 = (1.00000 * y0) + (0.00000 * cb) + (1.40200 * cr);
g0 = (1.00000 * y0) - (0.34414 * cb) - (0.71444 * cr);
b0 = (1.00000 * y0) + (1.72200 * cb) + (0.00000 * cr);

r1 = (1.00000 * y1) + (0.00000 * cb) + (1.40200 * cr);
g1 = (1.00000 * y1) - (0.34414 * cb) - (0.71444 * cr);
b1 = (1.00000 * y1) + (1.72200 * cb) + (0.00000 * cr);


if(r0 > 255) r0 = 255;
                        else if(r0 < 0) r0 = 0;
if(g0 > 255) g0 = 255;
else if(g0 < 0) g0 = 0;
if(b0 > 255) b0 = 255;
else if(b0 < 0) b0 = 0;

if(r1 > 255) r1 = 255;
else if(r1 < 0) r1 = 0;
if(g1 > 255) g1 = 255;
else if(g1 < 0) g1 = 0;
if(b1 > 255) b1 = 255;
else if(b1 < 0) b1 = 0;



*((Uint8*)0x83000000 + 6*j + l) = r0;
*((Uint8*)0x83000000 + 1 + 6*j + l) = g0;
*((Uint8*)0x83000000 + 2 + 6*j + l) = b0;
*((Uint8*)0x83000000 + 3 + 6*j + l) = r1;
*((Uint8*)0x83000000 + 4 + 6*j + l) = g1;
*((Uint8*)0x83000000 + 5 + 6*j + l) = b1;
}
}

vpbe_init( 0x83000000, 720, 480,0);   // Setup Back-End   
return 0;
}