Add ability to have multiple compound modes for interinter

This is currently just a refactor and creates no change in performance.
It allows new compound types to be added easily in the future to
facilitate experiments with segmentation masks.

Change-Id: If48fed216d482454fabb45a304b4220ada0dbdee
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 49e8b2d..f293a04 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -6955,7 +6955,7 @@
   *compmode_interintra_cost = 0;
   mbmi->use_wedge_interintra = 0;
   *compmode_wedge_cost = 0;
-  mbmi->use_wedge_interinter = 0;
+  mbmi->interinter_compound = COMPOUND_AVERAGE;
 
   // is_comp_interintra_pred implies !is_comp_pred
   assert(!is_comp_interintra_pred || (!is_comp_pred));
@@ -7360,9 +7360,12 @@
     int64_t best_rd_wedge = INT64_MAX;
     int tmp_skip_txfm_sb;
     int64_t tmp_skip_sse_sb;
+    int compound_type_cost[COMPOUND_TYPES];
 
-    rs2 = av1_cost_bit(cm->fc->wedge_interinter_prob[bsize], 0);
-    mbmi->use_wedge_interinter = 0;
+    mbmi->interinter_compound = COMPOUND_AVERAGE;
+    av1_cost_tokens(compound_type_cost, cm->fc->compound_type_prob[bsize],
+                    av1_compound_type_tree);
+    rs2 = compound_type_cost[mbmi->interinter_compound];
     av1_build_inter_predictors_sby(xd, mi_row, mi_col, bsize);
     av1_subtract_plane(x, bsize, 0);
     rd = estimate_yrd_for_sb(cpi, bsize, x, &rate_sum, &dist_sum,
@@ -7380,9 +7383,9 @@
       uint8_t *preds1[1] = { pred1 };
       int strides[1] = { bw };
 
-      mbmi->use_wedge_interinter = 1;
+      mbmi->interinter_compound = COMPOUND_WEDGE;
       rs2 = av1_cost_literal(get_interinter_wedge_bits(bsize)) +
-            av1_cost_bit(cm->fc->wedge_interinter_prob[bsize], 1);
+            compound_type_cost[mbmi->interinter_compound];
 
       av1_build_inter_predictors_for_planes_single_buf(
           xd, bsize, 0, 0, mi_row, mi_col, 0, preds0, strides);
@@ -7443,13 +7446,13 @@
         best_rd_wedge = rd;
 
         if (best_rd_wedge < best_rd_nowedge) {
-          mbmi->use_wedge_interinter = 1;
+          mbmi->interinter_compound = COMPOUND_WEDGE;
           xd->mi[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int;
           xd->mi[0]->bmi[0].as_mv[1].as_int = mbmi->mv[1].as_int;
           rd_stats->rate += tmp_rate_mv - rate_mv;
           rate_mv = tmp_rate_mv;
         } else {
-          mbmi->use_wedge_interinter = 0;
+          mbmi->interinter_compound = COMPOUND_AVERAGE;
           mbmi->mv[0].as_int = cur_mv[0].as_int;
           mbmi->mv[1].as_int = cur_mv[1].as_int;
           xd->mi[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int;
@@ -7466,9 +7469,9 @@
           rd = RDCOST(x->rdmult, x->rddiv, rs2 + rate_mv + rate_sum, dist_sum);
         best_rd_wedge = rd;
         if (best_rd_wedge < best_rd_nowedge) {
-          mbmi->use_wedge_interinter = 1;
+          mbmi->interinter_compound = COMPOUND_WEDGE;
         } else {
-          mbmi->use_wedge_interinter = 0;
+          mbmi->interinter_compound = COMPOUND_AVERAGE;
         }
       }
     }
@@ -7478,13 +7481,11 @@
 
     pred_exists = 0;
 
-    if (mbmi->use_wedge_interinter)
-      *compmode_wedge_cost =
-          av1_cost_literal(get_interinter_wedge_bits(bsize)) +
-          av1_cost_bit(cm->fc->wedge_interinter_prob[bsize], 1);
-    else
-      *compmode_wedge_cost =
-          av1_cost_bit(cm->fc->wedge_interinter_prob[bsize], 0);
+    *compmode_wedge_cost = compound_type_cost[mbmi->interinter_compound];
+
+    if (mbmi->interinter_compound)
+      *compmode_wedge_cost +=
+          av1_cost_literal(get_interinter_wedge_bits(bsize));
   }
 
   if (is_comp_interintra_pred) {
@@ -10170,7 +10171,7 @@
 #endif  // CONFIG_FILTER_INTRA
   mbmi->motion_mode = SIMPLE_TRANSLATION;
 #if CONFIG_EXT_INTER
-  mbmi->use_wedge_interinter = 0;
+  mbmi->interinter_compound = COMPOUND_AVERAGE;
   mbmi->use_wedge_interintra = 0;
 #endif  // CONFIG_EXT_INTER