From: divverent Date: Sun, 5 Apr 2009 09:51:24 +0000 (+0000) Subject: fix YUV tables X-Git-Tag: xonotic-v0.1.0preview~1740 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=51e492be00298984100b4851f80d83e076189dc2;p=xonotic%2Fdarkplaces.git fix YUV tables git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8867 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_screen.c b/cl_screen.c index ed6f31dc..66c2667e 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -1029,22 +1029,23 @@ Cr = R * .500 + G * -.419 + B * -.0813 + 128.; r = 255*cls.capturevideo.vidramp[i]/65535.0; g = 255*cls.capturevideo.vidramp[i+256]/65535.0; b = 255*cls.capturevideo.vidramp[i+512]/65535.0; + // NOTE: we have to round DOWN here, or integer overflows happen. Sorry for slightly wrong looking colors sometimes... // Y weights from RGB - cls.capturevideo.rgbtoyuvscaletable[0][0][i] = (short)(r * 0.299 + 0.5); - cls.capturevideo.rgbtoyuvscaletable[0][1][i] = (short)(g * 0.587 + 0.5); - cls.capturevideo.rgbtoyuvscaletable[0][2][i] = (short)(b * 0.114 + 0.5); + cls.capturevideo.rgbtoyuvscaletable[0][0][i] = (short)(r * 0.299); + cls.capturevideo.rgbtoyuvscaletable[0][1][i] = (short)(g * 0.587); + cls.capturevideo.rgbtoyuvscaletable[0][2][i] = (short)(b * 0.114); // Cb weights from RGB - cls.capturevideo.rgbtoyuvscaletable[1][0][i] = (short)(r * -0.169 + 0.5); - cls.capturevideo.rgbtoyuvscaletable[1][1][i] = (short)(g * -0.332 + 0.5); - cls.capturevideo.rgbtoyuvscaletable[1][2][i] = (short)(b * 0.500 + 0.5); + cls.capturevideo.rgbtoyuvscaletable[1][0][i] = (short)(r * -0.169); + cls.capturevideo.rgbtoyuvscaletable[1][1][i] = (short)(g * -0.332); + cls.capturevideo.rgbtoyuvscaletable[1][2][i] = (short)(b * 0.500); // Cr weights from RGB - cls.capturevideo.rgbtoyuvscaletable[2][0][i] = (short)(r * 0.500 + 0.5); - cls.capturevideo.rgbtoyuvscaletable[2][1][i] = (short)(g * -0.419 + 0.5); - cls.capturevideo.rgbtoyuvscaletable[2][2][i] = (short)(b * -0.0813 + 0.5); + cls.capturevideo.rgbtoyuvscaletable[2][0][i] = (short)(r * 0.500); + cls.capturevideo.rgbtoyuvscaletable[2][1][i] = (short)(g * -0.419); + cls.capturevideo.rgbtoyuvscaletable[2][2][i] = (short)(b * -0.0813); // range reduction of YCbCr to valid signal range - cls.capturevideo.yuvnormalizetable[0][i] = 16 + i * (236-16) / 256 + 0.5; - cls.capturevideo.yuvnormalizetable[1][i] = 16 + i * (240-16) / 256 + 0.5; - cls.capturevideo.yuvnormalizetable[2][i] = 16 + i * (240-16) / 256 + 0.5; + cls.capturevideo.yuvnormalizetable[0][i] = 16 + i * (236-16) / 256; + cls.capturevideo.yuvnormalizetable[1][i] = 16 + i * (240-16) / 256; + cls.capturevideo.yuvnormalizetable[2][i] = 16 + i * (240-16) / 256; } if (cl_capturevideo_ogg.integer)