From f4957d7a2646bdeaf089c4f7a566c736f5206f4c Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 8 Jun 2006 10:36:35 +0000 Subject: [PATCH] improved mc+src merge code git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18648 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/vf_mcdeint.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/libmpcodecs/vf_mcdeint.c b/libmpcodecs/vf_mcdeint.c index e54f39b0ae..47fa57e49b 100644 --- a/libmpcodecs/vf_mcdeint.c +++ b/libmpcodecs/vf_mcdeint.c @@ -89,7 +89,7 @@ struct vf_priv_s { }; static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int dst_stride[3], int src_stride[3], int width, int height){ - int x, y, i; + int x, y, i, j; int out_size; for(i=0; i<3; i++){ @@ -116,25 +116,35 @@ static void filter(struct vf_priv_s *p, uint8_t *dst[3], uint8_t *src[3], int ds if(x>0 && y>0 && x+1frame_dec->data[i][x + y*fils]; uint8_t *srcp= &src[i][x + y*srcs]; - int diff0= - filp[-1-fils] + 2*filp[-fils] + filp[1-fils] - -srcp[-1-srcs] - 2*srcp[-srcs] - srcp[1-srcs]; - int diff1= - +filp[-1+fils] + 2*filp[+fils] + filp[1+fils] - -srcp[-1+srcs] - 2*srcp[+srcs] - srcp[1+srcs]; + int diff0= filp[-fils] - srcp[-srcs]; + int diff1= filp[+fils] - srcp[+srcs]; + int diffscore= ABS(srcp[-srcs-1] - srcp[+srcs-1]) + +ABS(srcp[-srcs ] - srcp[+srcs ]) + +ABS(srcp[-srcs+1] - srcp[+srcs+1]); int temp= filp[0]; + + for(j=-1; j<=1; j+=2){ + int score= ABS(srcp[-srcs+j-1] - srcp[+srcs-j-1]) + +ABS(srcp[-srcs+j ] - srcp[+srcs-j ]) + +ABS(srcp[-srcs+j+1] - srcp[+srcs-j+1]) + 1; + if(score < diffscore){ + diffscore= score; + diff0= filp[-fils+j] - srcp[-srcs+j]; + diff1= filp[+fils-j] - srcp[+srcs-j]; + } + } #if 0 if((diff0 ^ diff1) > 0){ int mindiff= ABS(diff0) > ABS(diff1) ? diff1 : diff0; - temp-= (mindiff + 2)>>2; + temp-= mindiff; } #elif 1 if(diff0 + diff1 > 0) - temp-= (diff0 + diff1 - ABS( ABS(diff0) - ABS(diff1) )/2)/8; + temp-= (diff0 + diff1 - ABS( ABS(diff0) - ABS(diff1) )/2)/2; else - temp-= (diff0 + diff1 + ABS( ABS(diff0) - ABS(diff1) )/2)/8; + temp-= (diff0 + diff1 + ABS( ABS(diff0) - ABS(diff1) )/2)/2; #else - temp-= (diff0 + diff1)/8; + temp-= (diff0 + diff1)/2; #endif #if 1 filp[0]=