changeset 950:d4d714493faa libavcodec

bugfix
author michaelni
date Wed, 01 Jan 2003 16:47:31 +0000
parents 693a0797398f
children ad264a7d4f94
files motion_est.c
diffstat 1 files changed, 15 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/motion_est.c	Wed Jan 01 15:10:45 2003 +0000
+++ b/motion_est.c	Wed Jan 01 16:47:31 2003 +0000
@@ -1222,21 +1222,6 @@
     int16_t (*mv_table)[2]= s->b_direct_mv_table;
     uint16_t * const mv_penalty= s->me.mv_penalty[1] + MAX_MV;
     
-    P_LEFT[0]        = mv_table[mot_xy - 1][0];
-    P_LEFT[1]        = mv_table[mot_xy - 1][1];
-
-    /* special case for first line */
-    if ((mb_y == 0 || s->first_slice_line)) {
-    } else {
-        P_TOP[0] = mv_table[mot_xy - mot_stride             ][0];
-        P_TOP[1] = mv_table[mot_xy - mot_stride             ][1];
-        P_TOPRIGHT[0] = mv_table[mot_xy - mot_stride + 1         ][0];
-        P_TOPRIGHT[1] = mv_table[mot_xy - mot_stride + 1         ][1];
-    
-        P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
-        P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
-    }
-
     ymin= xmin=(-32)>>shift;
     ymax= xmax=   31>>shift;
 
@@ -1283,6 +1268,21 @@
         return 256*256*256*64;
     }
 
+    P_LEFT[0]        = clip(mv_table[mot_xy - 1][0], xmin<<shift, xmax<<shift);
+    P_LEFT[1]        = clip(mv_table[mot_xy - 1][1], ymin<<shift, ymax<<shift);
+
+    /* special case for first line */
+    if ((mb_y == 0 || s->first_slice_line)) {
+    } else {
+        P_TOP[0]      = clip(mv_table[mot_xy - mot_stride             ][0], xmin<<shift, xmax<<shift);
+        P_TOP[1]      = clip(mv_table[mot_xy - mot_stride             ][1], ymin<<shift, ymax<<shift);
+        P_TOPRIGHT[0] = clip(mv_table[mot_xy - mot_stride + 1         ][0], xmin<<shift, xmax<<shift);
+        P_TOPRIGHT[1] = clip(mv_table[mot_xy - mot_stride + 1         ][1], ymin<<shift, ymax<<shift);
+    
+        P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
+        P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
+    }
+    
     if(s->flags&CODEC_FLAG_QPEL){
         dmin = simple_direct_qpel_epzs_motion_search(s, 0, &mx, &my, P, 0, 0, xmin, ymin, xmax, ymax, 
                                                      &s->last_picture, mv_table, 1<<14, mv_penalty);