From 0382fdf50a926c6a6a73e12b057607d25d50e2af Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 9 Sep 2008 23:39:32 +0000 Subject: [PATCH] More accurate rounding for 8bit inputs. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27562 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libswscale/swscale.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 9dfe1f8e7c..8a9390a3d1 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -2671,9 +2671,9 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, g= ((i>>1)&3)*85; r= (i&1 )*255; } - y= av_clip_uint8(((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16 ); - u= av_clip_uint8(((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128); - v= av_clip_uint8(((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128); + y= av_clip_uint8((RY*r + GY*g + BY*b + ( 33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); + u= av_clip_uint8((RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); + v= av_clip_uint8((RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); pal[i]= y + (u<<8) + (v<<16); } src2[1]= (uint8_t*)pal;