Add improved_mv_pred flag in real-time mode
authorYunqing Wang <yunqingwang@google.com>
Fri, 11 Feb 2011 14:43:37 +0000 (09:43 -0500)
committerYunqing Wang <yunqingwang@google.com>
Fri, 11 Feb 2011 14:59:41 +0000 (09:59 -0500)
As mentioned in check-in "Improve motion search in real-time mode",
MV prediction calculation causes speed loss for speed 7 and above.
This change added a flag to turn off this calculation for speed>6
in real-time mode.

Change-Id: I9f4ae5a8bf449222d1784b54e7d315fc8347b2d1

vp8/encoder/onyx_if.c
vp8/encoder/onyx_int.h
vp8/encoder/pickinter.c

index 511631a..3211fe6 100644 (file)
@@ -601,6 +601,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
 
     sf->first_step = 0;
     sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
+    sf->improved_mv_pred = 1;
 
     cpi->do_full[0] = 0;
     cpi->do_full[1] = 0;
@@ -1228,6 +1229,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
             sf->thresh_mult[THR_V_PRED] = INT_MAX;
             sf->thresh_mult[THR_H_PRED] = INT_MAX;
 
+            sf->improved_mv_pred = 0;
         }
 
         if (Speed > 8)
index 0289b4a..d6e4942 100644 (file)
@@ -185,6 +185,7 @@ typedef struct
 
     int use_fastquant_for_pick;
     int no_skip_block4x4_search;
+    int improved_mv_pred;
 
 } SPEED_FEATURES;
 
index 0bfcd38..1a58257 100644 (file)
@@ -608,7 +608,7 @@ int vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rec
                 continue;
         }
 
-        if(x->e_mbd.mode_info_context->mbmi.mode == NEWMV)
+        if(cpi->sf.improved_mv_pred && x->e_mbd.mode_info_context->mbmi.mode == NEWMV)
         {
             if(!saddone)
             {
@@ -685,37 +685,50 @@ int vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rec
             int n = 0;
             int sadpb = x->sadperbit16;
 
-            int col_min = (best_ref_mv.col - MAX_FULL_PEL_VAL) >>3;
-            int col_max = (best_ref_mv.col + MAX_FULL_PEL_VAL) >>3;
-            int row_min = (best_ref_mv.row - MAX_FULL_PEL_VAL) >>3;
-            int row_max = (best_ref_mv.row + MAX_FULL_PEL_VAL) >>3;
+            int col_min;
+            int col_max;
+            int row_min;
+            int row_max;
 
             int tmp_col_min = x->mv_col_min;
             int tmp_col_max = x->mv_col_max;
             int tmp_row_min = x->mv_row_min;
             int tmp_row_max = x->mv_row_max;
 
-            // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
-            if (x->mv_col_min < col_min )
-                x->mv_col_min = col_min;
-            if (x->mv_col_max > col_max )
-                x->mv_col_max = col_max;
-            if (x->mv_row_min < row_min )
-                x->mv_row_min = row_min;
-            if (x->mv_row_max > row_max )
-                x->mv_row_max = row_max;
+            int speed_adjust = (cpi->Speed > 5) ? ((cpi->Speed >= 8)? 3 : 2) : 1;
 
             // Further step/diamond searches as necessary
+            step_param = cpi->sf.first_step + speed_adjust;
+
+            if(cpi->sf.improved_mv_pred)
             {
-                int speed_adjust = (cpi->Speed > 5) ? ((cpi->Speed >= 8)? 3 : 2) : 1;
-                step_param = cpi->sf.first_step + speed_adjust;
                 sr += speed_adjust;
                 //adjust search range according to sr from mv prediction
                 if(sr > step_param)
                     step_param = sr;
-                further_steps = (cpi->Speed >= 8)? 0: (cpi->sf.max_step_search_steps - 1 - step_param);
+
+                col_min = (best_ref_mv.col - MAX_FULL_PEL_VAL) >>3;
+                col_max = (best_ref_mv.col + MAX_FULL_PEL_VAL) >>3;
+                row_min = (best_ref_mv.row - MAX_FULL_PEL_VAL) >>3;
+                row_max = (best_ref_mv.row + MAX_FULL_PEL_VAL) >>3;
+
+                // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
+                if (x->mv_col_min < col_min )
+                    x->mv_col_min = col_min;
+                if (x->mv_col_max > col_max )
+                    x->mv_col_max = col_max;
+                if (x->mv_row_min < row_min )
+                    x->mv_row_min = row_min;
+                if (x->mv_row_max > row_max )
+                    x->mv_row_max = row_max;
+            }else
+            {
+                mvp.row = best_ref_mv.row;
+                mvp.col = best_ref_mv.col;
             }
 
+            further_steps = (cpi->Speed >= 8)? 0: (cpi->sf.max_step_search_steps - 1 - step_param);
+
             if (cpi->sf.search_method == HEX)
             {
                 bestsme = vp8_hex_search(x, b, d, &mvp, &d->bmi.mv.as_mv, step_param, sadpb/*x->errorperbit*/, &num00, &cpi->fn_ptr[BLOCK_16X16], x->mvsadcost, x->mvcost, &best_ref_mv);
@@ -760,10 +773,13 @@ int vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int rec
                 }
             }
 
-            x->mv_col_min = tmp_col_min;
-            x->mv_col_max = tmp_col_max;
-            x->mv_row_min = tmp_row_min;
-            x->mv_row_max = tmp_row_max;
+            if(cpi->sf.improved_mv_pred)
+            {
+                x->mv_col_min = tmp_col_min;
+                x->mv_col_max = tmp_col_max;
+                x->mv_row_min = tmp_row_min;
+                x->mv_row_max = tmp_row_max;
+            }
 
             if (bestsme < INT_MAX)
                 cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv.as_mv, &best_ref_mv, x->errorperbit, &cpi->fn_ptr[BLOCK_16X16], cpi->mb.mvcost);