changeset 691:199b324b2693 libavcodec

fixing variance scaling for b frames (messed adaptive quants up) cliping too long MVs in b frames instead of setting them to 0
author michaelni
date Mon, 23 Sep 2002 15:16:09 +0000
parents a1c69cb685b3
children 852b5a416161
files motion_est.c
diffstat 1 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/motion_est.c	Mon Sep 23 14:56:11 2002 +0000
+++ b/motion_est.c	Mon Sep 23 15:16:09 2002 +0000
@@ -1546,7 +1546,7 @@
             score=fbmin;
             type= MB_TYPE_BIDIR;
         }
-        score= (score*score)>>8;
+        score= (score*score + 128*256)>>16;
         s->mc_mb_var_sum += score;
         s->mc_mb_var[mb_y*s->mb_width + mb_x] = score; //FIXME use SSD
     }
@@ -1698,18 +1698,15 @@
         int xy= (y+1)* (s->mb_width+2)+1;
         int i= y*s->mb_width;
         for(x=0; x<s->mb_width; x++){
-            if(s->mb_type[i]&type){
-                if(   fcode_tab[mv_table[xy][0] + MAX_MV] > f_code
-                   || fcode_tab[mv_table[xy][0] + MAX_MV] == 0
-                   || fcode_tab[mv_table[xy][1] + MAX_MV] > f_code
-                   || fcode_tab[mv_table[xy][1] + MAX_MV] == 0 ){
-                    if(s->mb_type[i]&(~type)) s->mb_type[i] &= ~type;
-                    else{
-                        mv_table[xy][0] = 0;
-                        mv_table[xy][1] = 0;
-                        //this is certainly bad FIXME            
-                    }
-                }
+            if(   fcode_tab[mv_table[xy][0] + MAX_MV] > f_code
+               || fcode_tab[mv_table[xy][0] + MAX_MV] == 0){
+                if(mv_table[xy][0]>0) mv_table[xy][0]=  (16<<f_code)-1;
+                else                  mv_table[xy][0]= -(16<<f_code);
+            }
+            if(   fcode_tab[mv_table[xy][1] + MAX_MV] > f_code
+               || fcode_tab[mv_table[xy][1] + MAX_MV] == 0){
+                if(mv_table[xy][1]>0) mv_table[xy][1]=  (16<<f_code)-1;
+                else                  mv_table[xy][1]= -(16<<f_code);
             }
             xy++;
             i++;