| Ok, I've finally snapped |
I was just writing some code to manipulate a bitmap, something I need to do for my PhD (specifically, I'm converting YUV420P to RGB24). Anyhoo, the image isn't looking right, so before I go to sleep on it I thought I would dump the YUV values next to the RGB ones and see if I could eyeball the problem.
I swear that as I was writing this I was thinking -- "I'll let the compiler optimise and write for readability". Do you think I succeeded?
for(x = 0; x < 320; x++)
{
for(y = 0; y < 240; y++)
{
raster[((y + 480) * 640 * 2 + x + 640) * 3] =
realfile[640 * 480 + (y * 320 + x)];
raster[((y + 480) * 640 * 2 + x + 640) * 3 + 1] =
realfile[640 * 480 + (y * 320 + x)];
raster[((y + 480) * 640 * 2 + x + 640) * 3 + 2] =
realfile[640 * 480 + (y * 320 + x)];
raster[((y + 480) * 640 * 2 + x + 640 + 320) * 3] =
realfile[640 * 480 + (320 * 240) + (y * 320 + x)];
raster[((y + 480) * 640 * 2 + x + 640 + 320) * 3 + 1] =
realfile[640 * 480 + (320 * 240) + (y * 320 + x)];
raster[((y + 480) * 640 * 2 + x + 640 + 320) * 3 + 2] =
realfile[640 * 480 + (320 * 240) + (y * 320 + x)];
}
}
Here's the image I get at the moment:

See how the RGB image on the left isn't colorful enough? That pen there is lime green. Anyways, if anyone can see the problem and wants to give me a hint, that would be cool too.
Update: It would seem that the terms YUV420, YUV420P, iYUV, and I420 are all interchangeable, to add to the fun.
Technorati tags for this post: phd yuv rgb color space convert code
posted at: 17:46 | path: /phd | permanent link to this entry
Comment on this post.
