shithub: libvpx

Download patch

ref: f54b51579708c966c3035caeab952efb352b39f9
parent: d4b500d9d7d45643cf368ac0e1cf6859bad63540
parent: 098d13ba1074baeae2456291bcb4c90e7435632e
author: Dmitry Kovalev <dkovalev@google.com>
date: Fri Dec 13 10:38:53 EST 2013

Merge "Cleaning up vp9_append_sub8x8_mvs_for_idx()."

--- a/vp9/common/vp9_findnearmv.c
+++ b/vp9/common/vp9_findnearmv.c
@@ -36,46 +36,49 @@
 
 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
                                    const TileInfo *const tile,
-                                   int_mv *dst_nearest, int_mv *dst_near,
-                                   int block_idx, int ref_idx,
-                                   int mi_row, int mi_col) {
+                                   int block, int ref, int mi_row, int mi_col,
+                                   int_mv *nearest, int_mv *near) {
   int_mv mv_list[MAX_MV_REF_CANDIDATES];
   MODE_INFO *const mi = xd->mi_8x8[0];
   b_mode_info *bmi = mi->bmi;
   int n;
 
-  assert(ref_idx == 0 || ref_idx == 1);
   assert(MAX_MV_REF_CANDIDATES == 2);
 
-  vp9_find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi,
-                       mi->mbmi.ref_frame[ref_idx],
-                       mv_list, block_idx, mi_row, mi_col);
+  vp9_find_mv_refs_idx(cm, xd, tile, mi, xd->last_mi, mi->mbmi.ref_frame[ref],
+                       mv_list, block, mi_row, mi_col);
 
-  dst_near->as_int = 0;
-  if (block_idx == 0) {
-    dst_nearest->as_int = mv_list[0].as_int;
-    dst_near->as_int = mv_list[1].as_int;
-  } else if (block_idx == 1 || block_idx == 2) {
-    dst_nearest->as_int = bmi[0].as_mv[ref_idx].as_int;
-    for (n = 0; n < MAX_MV_REF_CANDIDATES; ++n)
-      if (dst_nearest->as_int != mv_list[n].as_int) {
-        dst_near->as_int = mv_list[n].as_int;
-        break;
-      }
-  } else {
-    int_mv candidates[2 + MAX_MV_REF_CANDIDATES];
-    candidates[0] = bmi[1].as_mv[ref_idx];
-    candidates[1] = bmi[0].as_mv[ref_idx];
-    candidates[2] = mv_list[0];
-    candidates[3] = mv_list[1];
+  near->as_int = 0;
+  switch (block) {
+    case 0:
+      nearest->as_int = mv_list[0].as_int;
+      near->as_int = mv_list[1].as_int;
+      break;
+    case 1:
+    case 2:
+      nearest->as_int = bmi[0].as_mv[ref].as_int;
+      for (n = 0; n < MAX_MV_REF_CANDIDATES; ++n)
+        if (nearest->as_int != mv_list[n].as_int) {
+          near->as_int = mv_list[n].as_int;
+          break;
+        }
+      break;
+    case 3: {
+      int_mv candidates[2 + MAX_MV_REF_CANDIDATES];
+      candidates[0] = bmi[1].as_mv[ref];
+      candidates[1] = bmi[0].as_mv[ref];
+      candidates[2] = mv_list[0];
+      candidates[3] = mv_list[1];
 
-    assert(block_idx == 3);
-    dst_nearest->as_int = bmi[2].as_mv[ref_idx].as_int;
-    for (n = 0; n < 2 + MAX_MV_REF_CANDIDATES; ++n) {
-      if (dst_nearest->as_int != candidates[n].as_int) {
-        dst_near->as_int = candidates[n].as_int;
-        break;
-      }
+      nearest->as_int = bmi[2].as_mv[ref].as_int;
+      for (n = 0; n < 2 + MAX_MV_REF_CANDIDATES; ++n)
+        if (nearest->as_int != candidates[n].as_int) {
+          near->as_int = candidates[n].as_int;
+          break;
+        }
+      break;
     }
+    default:
+      assert("Invalid block index.");
   }
 }
--- a/vp9/common/vp9_findnearmv.h
+++ b/vp9/common/vp9_findnearmv.h
@@ -36,9 +36,7 @@
 
 void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
                                    const TileInfo *const tile,
-                                   int_mv *dst_nearest,
-                                   int_mv *dst_near,
-                                   int block_idx, int ref_idx,
-                                   int mi_row, int mi_col);
+                                   int block, int ref, int mi_row, int mi_col,
+                                   int_mv *nearest, int_mv *near);
 
 #endif  // VP9_COMMON_VP9_FINDNEARMV_H_
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -475,8 +475,8 @@
 
         if (b_mode == NEARESTMV || b_mode == NEARMV)
           for (ref = 0; ref < 1 + is_compound; ++ref)
-            vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, &nearest[ref],
-                                          &nearmv[ref], j, ref, mi_row, mi_col);
+            vp9_append_sub8x8_mvs_for_idx(cm, xd, tile, j, ref, mi_row, mi_col,
+                                          &nearest[ref], &nearmv[ref]);
 
         if (!assign_mv(cm, b_mode, block, best, nearest, nearmv,
                        is_compound, allow_hp, r)) {
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1669,15 +1669,15 @@
 
       frame_mv[ZEROMV][mbmi->ref_frame[0]].as_int = 0;
       vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, tile,
+                                    i, 0, mi_row, mi_col,
                                     &frame_mv[NEARESTMV][mbmi->ref_frame[0]],
-                                    &frame_mv[NEARMV][mbmi->ref_frame[0]],
-                                    i, 0, mi_row, mi_col);
+                                    &frame_mv[NEARMV][mbmi->ref_frame[0]]);
       if (has_second_rf) {
         frame_mv[ZEROMV][mbmi->ref_frame[1]].as_int = 0;
         vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd, tile,
+                                      i, 1, mi_row, mi_col,
                                       &frame_mv[NEARESTMV][mbmi->ref_frame[1]],
-                                      &frame_mv[NEARMV][mbmi->ref_frame[1]],
-                                      i, 1, mi_row, mi_col);
+                                      &frame_mv[NEARMV][mbmi->ref_frame[1]]);
       }
       // search for the best motion vector on this segment
       for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {