Hallo!
the problem is (i believe), that YUV does not use the whole range from 0..255 but something like 16..245 (or whatever: i didn't write it down and now i cannot find it); i didn't add any clipping for this (which was very stupid) because of performance reasons.
It fixed this for me some months ago, but didn't send it to the list (because I also changed the colors r and b because they were swapped with my webcam ...)
e.g.: GemPixUtil.cpp, line 599:
case GL_RGBA: case GL_BGRA_EXT: // <- this is the confusing: // RGBA and BGRA is the same !!! {
... // 1st row - 1st pixel y=*py1++; yy=y<<8; //*pixels1++ = (yy + ub ) >> 8; // r *pixels1++ = CLAMP( (yy + vr) >> 8 ); // r *pixels1++ = CLAMP( (yy - ug - vg) >> 8 ); // g //*pixels1++ = (yy + vr) >> 8; // b *pixels1++ = CLAMP( (yy + ub ) >> 8 ); // b *pixels1++ = 255; // a ...
}
so i think you only have to CLAMP the values (at least for me it worked much better this way)
LG Georg
oh, bless the lazy, but i really have to find the docs somewhere.
mfg.asd.r IOhannes
GEM-dev mailing list GEM-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/gem-dev
...and we have a winner! Ok, I'll commit this stuff (fromYV12(short*)), but should we add this clamping to the other functions (ie. fromUYVY, fromYUY2, fromYVYU)?
thanx georg! Now onto altivec...this file is gonna be huge!
jamie
On Feb 22, 2005, at 10:20 AM, Georg Holzmann wrote:
Hallo!
the problem is (i believe), that YUV does not use the whole range from 0..255 but something like 16..245 (or whatever: i didn't write it down and now i cannot find it); i didn't add any clipping for this (which was very stupid) because of performance reasons.
It fixed this for me some months ago, but didn't send it to the list (because I also changed the colors r and b because they were swapped with my webcam ...)
e.g.: GemPixUtil.cpp, line 599:
case GL_RGBA: case GL_BGRA_EXT: // <- this is the confusing: // RGBA and BGRA is the same !!! {
...
// 1st row - 1st pixel y=*py1++; yy=y<<8; //*pixels1++ = (yy + ub ) >> 8; // r *pixels1++ = CLAMP( (yy + vr) >> 8 ); // r *pixels1++ = CLAMP( (yy - ug - vg) >> 8 ); // g //*pixels1++ = (yy + vr) >> 8; // b *pixels1++ = CLAMP( (yy + ub ) >> 8 ); // b *pixels1++ = 255; // a
...
}
so i think you only have to CLAMP the values (at least for me it worked much better this way)
http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC28
These are the correct coefficients for all YUV <-> RGB transforms used throughout the industry. GEM should be no different.
cgc