changeset 18657:26f54fad099c

better spatial interpolation
author michael
date Fri, 09 Jun 2006 10:29:35 +0000
parents e30061e7e1f8
children dd0662509fcc
files libmpcodecs/vf_mcdeint.c libmpcodecs/vf_yadif.c
diffstat 2 files changed, 27 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_mcdeint.c	Thu Jun 08 22:39:45 2006 +0000
+++ b/libmpcodecs/vf_mcdeint.c	Fri Jun 09 10:29:35 2006 +0000
@@ -89,7 +89,7 @@
 };
 
 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, j;
+    int x, y, i;
     int out_size;
 
     for(i=0; i<3; i++){
@@ -118,21 +118,22 @@
                         uint8_t *srcp= &src[i][x + y*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 spatial_score= ABS(srcp[-srcs-1] - srcp[+srcs-1])
+                                          +ABS(srcp[-srcs  ] - srcp[+srcs  ])
+                                          +ABS(srcp[-srcs+1] - srcp[+srcs+1]) - 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];
-                            }
-                        }
+#define CHECK(j)\
+    {   int score= ABS(srcp[-srcs-1+j] - srcp[+srcs-1-j])\
+                 + ABS(srcp[-srcs  +j] - srcp[+srcs  -j])\
+                 + ABS(srcp[-srcs+1+j] - srcp[+srcs+1-j]);\
+        if(score < spatial_score){\
+            spatial_score= score;\
+            diff0= filp[-fils+j] - srcp[-srcs+j];\
+            diff1= filp[+fils-j] - srcp[+srcs-j];
+
+                        CHECK(-1) CHECK(-2) }} }}
+                        CHECK( 1) CHECK( 2) }} }}
 #if 0
                         if((diff0 ^ diff1) > 0){
                             int mindiff= ABS(diff0) > ABS(diff1) ? diff1 : diff0;
--- a/libmpcodecs/vf_yadif.c	Thu Jun 08 22:39:45 2006 +0000
+++ b/libmpcodecs/vf_yadif.c	Fri Jun 09 10:29:35 2006 +0000
@@ -65,7 +65,7 @@
 }
 
 static void filter(struct vf_priv_s *p, uint8_t *dst[3], int dst_stride[3], int width, int height, int parity, int tff){
-    int x, y, i, j;
+    int x, y, i;
 
     for(i=0; i<3; i++){
         int is_chroma= !!i;
@@ -91,18 +91,19 @@
                         int diff= MAX3(temporal_diff0>>1, temporal_diff1, temporal_diff2);
                         int spatial_pred= (c+e)>>1;
                         int spatial_score= ABS(cur[-refs-1] - cur[+refs-1]) + ABS(c-e)
-                                         + ABS(cur[-refs+1] - cur[+refs+1]);
+                                         + ABS(cur[-refs+1] - cur[+refs+1]) - 1;
 
-                        for(j=-1; j<=1; j+=2){
-                            int score= ABS(cur[-refs-1+j] - cur[+refs-1-j])
-                                     + ABS(cur[-refs  +j] - cur[+refs  -j])
-                                     + ABS(cur[-refs+1+j] - cur[+refs+1-j]) + 1;
+#define CHECK(j)\
+    {   int score= ABS(cur[-refs-1+j] - cur[+refs-1-j])\
+                 + ABS(cur[-refs  +j] - cur[+refs  -j])\
+                 + ABS(cur[-refs+1+j] - cur[+refs+1-j]);\
+        if(score < spatial_score){\
+            spatial_score= score;\
+            spatial_pred= (cur[-refs  +j] + cur[+refs  -j])>>1;\
 
-                            if(score < spatial_score){
-                                spatial_score= score;
-                                spatial_pred= (cur[-refs  +j] + cur[+refs  -j])>>1;
-                            }
-                        }
+                        CHECK(-1) CHECK(-2) }} }}
+                        CHECK( 1) CHECK( 2) }} }}
+
                         if(p->mode<2){
                             int b= (prev2[-2*refs] + next2[-2*refs])>>1;
                             int f= (prev2[+2*refs] + next2[+2*refs])>>1;