From 2d4929e340901cece322208f25bea3bc4ddaa440 Mon Sep 17 00:00:00 2001
From: "Ronald S. Bultje" <rbultje@google.com>
Date: Wed, 17 Jul 2013 16:46:53 -0700
Subject: [PATCH] Remove motion vectors from PARTITION_INFO.

The same information already exists in union b_mode_info.

Change-Id: Iac5086b99a3c3cc270380138062bb693e58f9e6d
---
 vp9/encoder/vp9_bitstream.c   |  4 ++--
 vp9/encoder/vp9_block.h       |  3 ---
 vp9/encoder/vp9_encodeframe.c |  4 ++--
 vp9/encoder/vp9_encodemv.c    | 11 ++++++-----
 vp9/encoder/vp9_rdopt.c       | 28 +++++++---------------------
 5 files changed, 17 insertions(+), 33 deletions(-)

diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index bd2928e081..611df7a77b 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -505,7 +505,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
         for (idx = 0; idx < 2; idx += bw) {
           j = idy * 2 + idx;
           blockmode = cpi->mb.partition_info->bmi[j].mode;
-          blockmv = cpi->mb.partition_info->bmi[j].mv;
+          blockmv = m->bmi[j].as_mv[0];
           write_sb_mv_ref(bc, blockmode, mv_ref_p);
           vp9_accum_mv_refs(&cpi->common, blockmode, mi->mb_mode_context[rf]);
           if (blockmode == NEWMV) {
@@ -517,7 +517,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
 
             if (mi->ref_frame[1] > INTRA_FRAME)
               vp9_encode_mv(cpi, bc,
-                            &cpi->mb.partition_info->bmi[j].second_mv.as_mv,
+                            &m->bmi[j].as_mv[1].as_mv,
                             &mi->best_second_mv.as_mv,
                             nmvc, xd->allow_high_precision_mv);
           }
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h
index b4c06f5dd5..d6882d5859 100644
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -24,11 +24,8 @@ typedef struct {
 } search_site;
 
 typedef struct {
-  int count;
   struct {
     MB_PREDICTION_MODE mode;
-    int_mv mv;
-    int_mv second_mv;
   } bmi[4];
 } PARTITION_INFO;
 
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index e773c38c7b..5d9471ea79 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -352,8 +352,8 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
 
   if (mbmi->ref_frame[0] != INTRA_FRAME && mbmi->sb_type < BLOCK_SIZE_SB8X8) {
     *x->partition_info = ctx->partition_info;
-    mbmi->mv[0].as_int = x->partition_info->bmi[3].mv.as_int;
-    mbmi->mv[1].as_int = x->partition_info->bmi[3].second_mv.as_int;
+    mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
+    mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
   }
 
   x->skip = ctx->skip;
diff --git a/vp9/encoder/vp9_encodemv.c b/vp9/encoder/vp9_encodemv.c
index f309c1c2b5..500f57442e 100644
--- a/vp9/encoder/vp9_encodemv.c
+++ b/vp9/encoder/vp9_encodemv.c
@@ -510,7 +510,8 @@ void vp9_build_nmv_cost_table(int *mvjoint,
 
 void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
                          int_mv *best_ref_mv, int_mv *second_best_ref_mv) {
-  MB_MODE_INFO *mbmi = &x->e_mbd.mode_info_context->mbmi;
+  MODE_INFO *mi = x->e_mbd.mode_info_context;
+  MB_MODE_INFO *const mbmi = &mi->mbmi;
   MV diff;
   const int bw = 1 << b_width_log2(mbmi->sb_type);
   const int bh = 1 << b_height_log2(mbmi->sb_type);
@@ -522,14 +523,14 @@ void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
       for (idx = 0; idx < 2; idx += bw) {
         const int i = idy * 2 + idx;
         if (pi->bmi[i].mode == NEWMV) {
-          diff.row = pi->bmi[i].mv.as_mv.row - best_ref_mv->as_mv.row;
-          diff.col = pi->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col;
+          diff.row = mi->bmi[i].as_mv[0].as_mv.row - best_ref_mv->as_mv.row;
+          diff.col = mi->bmi[i].as_mv[0].as_mv.col - best_ref_mv->as_mv.col;
           vp9_inc_mv(&diff, &cpi->NMVcount);
 
           if (x->e_mbd.mode_info_context->mbmi.ref_frame[1] > INTRA_FRAME) {
-            diff.row = pi->bmi[i].second_mv.as_mv.row -
+            diff.row = mi->bmi[i].as_mv[1].as_mv.row -
                          second_best_ref_mv->as_mv.row;
-            diff.col = pi->bmi[i].second_mv.as_mv.col -
+            diff.col = mi->bmi[i].as_mv[1].as_mv.col -
                          second_best_ref_mv->as_mv.col;
             vp9_inc_mv(&diff, &cpi->NMVcount);
           }
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index f62f2486f9..aea39f2e4e 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1641,9 +1641,6 @@ static int labels2mode(MACROBLOCK *x, int i,
     mic->bmi[i].as_mv[1].as_int = this_second_mv->as_int;
 
   x->partition_info->bmi[i].mode = m;
-  x->partition_info->bmi[i].mv.as_int = this_mv->as_int;
-  if (mbmi->ref_frame[1] > 0)
-    x->partition_info->bmi[i].second_mv.as_int = this_second_mv->as_int;
   for (idy = 0; idy < bh; ++idy) {
     for (idx = 0; idx < bw; ++idx) {
       vpx_memcpy(&mic->bmi[i + idy * 2 + idx],
@@ -1806,7 +1803,8 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
   int i, j, br = 0, rate = 0, sbr = 0, idx, idy;
   int64_t bd = 0, sbd = 0, subblock_sse = 0, block_sse = 0;
   MB_PREDICTION_MODE this_mode;
-  MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
+  MODE_INFO *mi = x->e_mbd.mode_info_context;
+  MB_MODE_INFO *const mbmi = &mi->mbmi;
   const int label_count = 4;
   int64_t this_segment_rd = 0;
   int label_mv_thresh;
@@ -2080,9 +2078,9 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
 
   // store everything needed to come back to this!!
   for (i = 0; i < 4; i++) {
-    bsi->mvs[i].as_mv = x->partition_info->bmi[i].mv.as_mv;
+    bsi->mvs[i].as_mv = mi->bmi[i].as_mv[0].as_mv;
     if (mbmi->ref_frame[1] > 0)
-      bsi->second_mvs[i].as_mv = x->partition_info->bmi[i].second_mv.as_mv;
+      bsi->second_mvs[i].as_mv = mi->bmi[i].as_mv[1].as_mv;
     bsi->modes[i] = x->partition_info->bmi[i].mode;
     bsi->eobs[i] = best_eobs[i];
   }
@@ -2123,24 +2121,12 @@ static int64_t rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
       x->e_mbd.mode_info_context->bmi[i].as_mv[1].as_int =
       bsi.second_mvs[i].as_int;
     x->e_mbd.plane[0].eobs[i] = bsi.eobs[i];
-  }
-
-  /* save partitions */
-  x->partition_info->count = 4;
-
-  for (i = 0; i < x->partition_info->count; i++) {
     x->partition_info->bmi[i].mode = bsi.modes[i];
-    x->partition_info->bmi[i].mv.as_mv = bsi.mvs[i].as_mv;
-    if (mbmi->ref_frame[1] > 0)
-      x->partition_info->bmi[i].second_mv.as_mv = bsi.second_mvs[i].as_mv;
   }
+
   /*
    * used to set mbmi->mv.as_int
    */
-  x->partition_info->bmi[3].mv.as_int = bsi.mvs[3].as_int;
-  if (mbmi->ref_frame[1] > 0)
-    x->partition_info->bmi[3].second_mv.as_int = bsi.second_mvs[3].as_int;
-
   *returntotrate = bsi.r;
   *returndistortion = bsi.d;
   *returnyrate = bsi.segment_yrate;
@@ -4041,8 +4027,8 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
 
     *x->partition_info = best_partition;
 
-    mbmi->mv[0].as_int = x->partition_info->bmi[3].mv.as_int;
-    mbmi->mv[1].as_int = x->partition_info->bmi[3].second_mv.as_int;
+    mbmi->mv[0].as_int = xd->mode_info_context->bmi[3].as_mv[0].as_int;
+    mbmi->mv[1].as_int = xd->mode_info_context->bmi[3].as_mv[1].as_int;
   }
 
   for (i = 0; i < NB_PREDICTION_TYPES; ++i) {
-- 
GitLab