ncobmc_adapt_weight: Add bitstream syntax

Define the syntax and entropy coding templates for
NCOBMC_ADAPT_WEIGHT. The actual values of the default
probabilities and the index tree structure need to
be fine tuned.

In this experiment all mv's in a superblock are sent
first as in the ncobmc case.

Change-Id: I68d50d3d27346c2847ea449a1168c6a99fbb4d3d
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 9ccdc8d..0b99b42 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -330,6 +330,29 @@
   }
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 }
+
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+static void read_ncobmc_mode(AV1_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *mi,
+                             NCOBMC_MODE ncobmc_mode[2], aom_reader *r) {
+  MB_MODE_INFO *mbmi = &mi->mbmi;
+  FRAME_COUNTS *counts = xd->counts;
+  ADAPT_OVERLAP_BLOCK ao_block = adapt_overlap_block_lookup[mbmi->sb_type];
+
+  if (ncobmc_mode_allowed(mbmi->sb_type) == NO_OVERLAP ||
+      ao_block == ADAPT_OVERLAP_BLOCK_INVALID)
+    return;
+
+  ncobmc_mode[0] = aom_read_tree(r, av1_ncobmc_mode_tree,
+                                 cm->fc->ncobmc_mode_prob[ao_block], ACCT_STR);
+  if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[0]];
+
+  if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
+    ncobmc_mode[1] = aom_read_tree(
+        r, av1_ncobmc_mode_tree, cm->fc->ncobmc_mode_prob[ao_block], ACCT_STR);
+    if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[1]];
+  }
+}
+#endif
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
@@ -2544,6 +2567,11 @@
     if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
       mbmi->motion_mode = read_motion_mode(cm, xd, mi, r);
+
+#if CONFIG_NCOBMC_ADAPT_WEIGHT
+    read_ncobmc_mode(cm, xd, mi, mbmi->ncobmc_mode, r);
+#endif
+
 #if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
     if (is_singleref_comp_mode) assert(mbmi->motion_mode == SIMPLE_TRANSLATION);
 #endif  // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF