]> granicus.if.org Git - libvpx/commitdiff
Refactor the sub8x8 block motion search control
authorJingning Han <jingning@google.com>
Mon, 28 Mar 2016 21:50:11 +0000 (14:50 -0700)
committerJingning Han <jingning@google.com>
Tue, 29 Mar 2016 16:53:55 +0000 (09:53 -0700)
Change-Id: Ia340e66e0a61403070adf8e4f18f00eab143f8f7

vp10/encoder/rdopt.c

index f3056e9aa06618f4f33396e7fd376b4aa7b60148..871a62e9152a989f4a89dba380186add8206742b 100644 (file)
@@ -4954,44 +4954,54 @@ static int64_t rd_pick_best_sub8x8_mode(VP10_COMP *cpi, MACROBLOCK *x,
 #if !CONFIG_EXT_INTER
         if (filter_idx > 0) {
           BEST_SEG_INFO* ref_bsi = bsi_buf;
-          if (seg_mvs[i][mbmi->ref_frame[0]].as_int ==
-              ref_bsi->rdstat[i][mode_idx].mvs[0].as_int &&
-              ref_bsi->rdstat[i][mode_idx].mvs[0].as_int != INVALID_MV)
-            if (bsi->ref_mv[0]->as_int ==
-                ref_bsi->rdstat[i][mode_idx].pred_mv[0].as_int)
-              --run_mv_search;
-
-          if (!has_second_rf) {
-            --run_mv_search;
-          } else {
+          SEG_RDSTAT *ref_rdstat = &ref_bsi->rdstat[i][mode_idx];
+
+          if (has_second_rf) {
+            if (seg_mvs[i][mbmi->ref_frame[0]].as_int ==
+                    ref_rdstat->mvs[0].as_int &&
+                ref_rdstat->mvs[0].as_int != INVALID_MV)
+              if (bsi->ref_mv[0]->as_int == ref_rdstat->pred_mv[0].as_int)
+                --run_mv_search;
+
             if (seg_mvs[i][mbmi->ref_frame[1]].as_int ==
-                ref_bsi->rdstat[i][mode_idx].mvs[1].as_int &&
-                ref_bsi->rdstat[i][mode_idx].mvs[1].as_int != INVALID_MV)
-              if (bsi->ref_mv[1]->as_int ==
-                  ref_bsi->rdstat[i][mode_idx].pred_mv[1].as_int)
+                    ref_rdstat->mvs[1].as_int &&
+                ref_rdstat->mvs[1].as_int != INVALID_MV)
+              if (bsi->ref_mv[1]->as_int == ref_rdstat->pred_mv[1].as_int)
                 --run_mv_search;
+          } else {
+            if (bsi->ref_mv[0]->as_int == ref_rdstat->pred_mv[0].as_int &&
+                ref_rdstat->mvs[0].as_int != INVALID_MV) {
+              run_mv_search = 0;
+              seg_mvs[i][mbmi->ref_frame[0]].as_int =
+                  ref_rdstat->mvs[0].as_int;
+            }
           }
 
           if (run_mv_search != 0 && filter_idx > 1) {
             ref_bsi = bsi_buf + 1;
+            ref_rdstat = &ref_bsi->rdstat[i][mode_idx];
             run_mv_search = 2;
 
-            if (seg_mvs[i][mbmi->ref_frame[0]].as_int ==
-                ref_bsi->rdstat[i][mode_idx].mvs[0].as_int &&
-                ref_bsi->rdstat[i][mode_idx].mvs[0].as_int != INVALID_MV)
-              if (bsi->ref_mv[0]->as_int ==
-                  ref_bsi->rdstat[i][mode_idx].pred_mv[0].as_int)
-                --run_mv_search;
+            if (has_second_rf) {
+              if (seg_mvs[i][mbmi->ref_frame[0]].as_int ==
+                      ref_rdstat->mvs[0].as_int &&
+                  ref_rdstat->mvs[0].as_int != INVALID_MV)
+                if (bsi->ref_mv[0]->as_int == ref_rdstat->pred_mv[0].as_int)
+                  --run_mv_search;
 
-            if (!has_second_rf) {
-              --run_mv_search;
-            } else {
               if (seg_mvs[i][mbmi->ref_frame[1]].as_int ==
-                  ref_bsi->rdstat[i][mode_idx].mvs[1].as_int &&
-                  ref_bsi->rdstat[i][mode_idx].mvs[1].as_int != INVALID_MV)
-                if (bsi->ref_mv[1]->as_int ==
-                    ref_bsi->rdstat[i][mode_idx].pred_mv[1].as_int)
+                      ref_rdstat->mvs[1].as_int &&
+                  ref_rdstat->mvs[1].as_int != INVALID_MV)
+                if (bsi->ref_mv[1]->as_int == ref_rdstat->pred_mv[1].as_int)
                   --run_mv_search;
+            } else {
+              if (bsi->ref_mv[0]->as_int ==
+                      ref_rdstat->pred_mv[0].as_int &&
+                  ref_rdstat->mvs[0].as_int != INVALID_MV) {
+                run_mv_search = 0;
+                seg_mvs[i][mbmi->ref_frame[0]].as_int =
+                    ref_rdstat->mvs[0].as_int;
+              }
             }
           }
         }
@@ -5071,8 +5081,8 @@ static int64_t rd_pick_best_sub8x8_mode(VP10_COMP *cpi, MACROBLOCK *x,
           }
 
 #if CONFIG_REF_MV
-          mvp_full.row = best_ref_mv->as_mv.row >> 3;
-          mvp_full.col = best_ref_mv->as_mv.col >> 3;
+          mvp_full.row = bsi->ref_mv[0]->as_mv.row >> 3;
+          mvp_full.col = bsi->ref_mv[0]->as_mv.col >> 3;
 #else
           mvp_full.row = bsi->mvp.as_mv.row >> 3;
           mvp_full.col = bsi->mvp.as_mv.col >> 3;