PDA

View Full Version : interlaced images



10-31-2003, 10:53 AM
Hi, im using the yuv colorspace to implement a video codec. In the player part, I had to do a yuv-rgb converter, which algorithm i got from the internet. But when i show it on the screen using opengl the image appears wrong. I tried to open the image in the adobe photoshop, and the image appears correct just when i select the interlaced option, otherwise the image apears wrong too. The converter algorithm save the r,g and b components sequentially, each one with 8 bits, as the follows:
unsigned char *yb,*ub,*vb,*ptr;
int Y,U,V,r,g,b,x,y;
yb = Ycomponent;
ub = Ucomponent;
vb = Vcomponent;
for (y=0; y<height; y++){
for (x=0; x<width; x++){
Y = *yb++;
U = (unsigned char)*ub++;
V = (unsigned char)*vb++;
U -= 128;
V -= 128;
r = clip(Y+V); //between 0..255
b = clip(Y+U); //between 0..255
g = clip(((Y*436L) >> 8) - ((r*130U) >> 8) - ((b*50U) >> 8)); //between 0..255
*ptr++ = r;
*ptr++ = g;
*ptr++ = b;
}
}
does anybody know how to change this algorithm to the data becomes non-interlaced, or whatever the problem?

thanks a lot