[MPlayer-dev-eng] rgb<->yuv convertion question

D Richard Felker III dalias at aerifal.cx
Thu Jan 15 18:07:10 CET 2004


On Thu, Jan 15, 2004 at 11:04:59AM +0100, armin.gerritsen at philips.com wrote:
> Just some things I quickly saw. Don't shoot me if I miss something. :-)
> 
> >>>> Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
> >>>> Cr = V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
> >>>> Cb = U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128
> 
> I tried this quickly in one of my reference programs which converts
> still-images and I see no red dots.
> So I guess it goes indeed wrong when rounding.
> 
> > i put my Clamp function:
> > unsigned char Clamp(float i) {
> > if (i>256.0f)
> > return 256;
> 
> if ( i>255.0f)
>  return 255;
> 
> When you use 256 and 'round' it to a unsigned char, you get 0.
> Codes 0 and 255 are, however, reserved for synchronisation purposes, and are
> prohibited from appearing in video data in the CIR601 (most common)
> YUV-standard.

Usuaully no one cares about CIR601. Many movies use the full 0-255
range.

Rich




More information about the MPlayer-dev-eng mailing list