]> granicus.if.org Git - libvpx/commitdiff
Some refactoring to support warped motion mode
authorDebargha Mukherjee <debargha@google.com>
Thu, 9 Jun 2016 07:57:09 +0000 (00:57 -0700)
committerDebargha Mukherjee <debargha@google.com>
Fri, 10 Jun 2016 19:04:18 +0000 (12:04 -0700)
Change-Id: I15d54a3ae48b2b33082668116792c6595bdb3ddb

12 files changed:
vp10/common/blockd.h
vp10/common/entropymode.c
vp10/common/entropymode.h
vp10/common/enums.h
vp10/common/reconinter.c
vp10/decoder/decodeframe.c
vp10/decoder/decodemv.c
vp10/encoder/bitstream.c
vp10/encoder/encodeframe.c
vp10/encoder/encoder.h
vp10/encoder/rd.c
vp10/encoder/rdopt.c

index 87e5d1c278f39f0cc71abeac870cf7ec34ab41aa..4c92c0aa7531bed5b5d0253800014ace537bf8f5 100644 (file)
@@ -202,11 +202,7 @@ typedef struct {
   int interinter_wedge_index;
   int interinter_wedge_sign;
 #endif  // CONFIG_EXT_INTER
-
-#if CONFIG_OBMC
-  int8_t obmc;
-#endif  // CONFIG_OBMC
-
+  MOTION_VARIATION motion_variation;
   int_mv mv[2];
   int_mv pred_mv[2];
 #if CONFIG_REF_MV
@@ -710,8 +706,8 @@ static INLINE int is_interintra_pred(const MB_MODE_INFO *mbmi) {
 }
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_OBMC
-static INLINE int is_obmc_allowed(const MB_MODE_INFO *mbmi) {
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+static INLINE int is_motvar_allowed(const MB_MODE_INFO *mbmi) {
 #if CONFIG_EXT_INTER
   return (mbmi->sb_type >= BLOCK_8X8 && mbmi->ref_frame[1] != INTRA_FRAME);
 #else
@@ -719,10 +715,12 @@ static INLINE int is_obmc_allowed(const MB_MODE_INFO *mbmi) {
 #endif  // CONFIG_EXT_INTER
 }
 
+#if CONFIG_OBMC
 static INLINE int is_neighbor_overlappable(const MB_MODE_INFO *mbmi) {
   return (is_inter_block(mbmi));
 }
 #endif  // CONFIG_OBMC
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 #ifdef __cplusplus
 }  // extern "C"
index 29fb27e7c16e975904ef50afa1e27ab18f86103c..63ef9cf9b875b377406283a65d401f2c347b8f2d 100644 (file)
@@ -295,15 +295,58 @@ static const vpx_prob default_wedge_interinter_prob[BLOCK_SIZES] = {
 };
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_OBMC
-static const vpx_prob default_obmc_prob[BLOCK_SIZES] = {
-    255, 255, 255, 151, 153, 144, 178, 165, 160, 207, 195, 168, 244,
+// Change this section appropriately once warped motion is supported
+#if CONFIG_OBMC && !CONFIG_WARPED_MOTION
+const vpx_tree_index vp10_motvar_tree[TREE_SIZE(MOTION_VARIATIONS)] = {
+  -SIMPLE_TRANSLATION, -OBMC_CAUSAL
+};
+static
+const vpx_prob default_motvar_prob[BLOCK_SIZES][MOTION_VARIATIONS - 1] = {
+  {255},
+  {255}, {255}, {151},
+  {153}, {144}, {178},
+  {165}, {160}, {207},
+  {195}, {168}, {244},
+#if CONFIG_EXT_PARTITION
+  {252}, {252}, {252},
+#endif  // CONFIG_EXT_PARTITION
+};
+
+#elif !CONFIG_OBMC && CONFIG_WARPED_MOTION
+
+const vpx_tree_index vp10_motvar_tree[TREE_SIZE(MOTION_VARIATIONS)] = {
+  -SIMPLE_TRANSLATION, -WARPED_CAUSAL
+};
+static
+const vpx_prob default_motvar_prob[BLOCK_SIZES][MOTION_VARIATIONS - 1] = {
+  {255},
+  {255}, {255}, {151},
+  {153}, {144}, {178},
+  {165}, {160}, {207},
+  {195}, {168}, {244},
+#if CONFIG_EXT_PARTITION
+  {252}, {252}, {252},
+#endif  // CONFIG_EXT_PARTITION
+};
+
+#elif CONFIG_OBMC && CONFIG_WARPED_MOTION
+
+const vpx_tree_index vp10_motvar_tree[TREE_SIZE(MOTION_VARIATIONS)] = {
+  -SIMPLE_TRANSLATION, 2,
+  -OBMC_CAUSAL, -WARPED_CAUSAL,
+};
+static
+const vpx_prob default_motvar_prob[BLOCK_SIZES][MOTION_VARIATIONS - 1] = {
+  {255, 200},
+  {255, 200}, {255, 200}, {151, 200},
+  {153, 200}, {144, 200}, {178, 200},
+  {165, 200}, {160, 200}, {207, 200},
+  {195, 200}, {168, 200}, {244, 200},
 #if CONFIG_EXT_PARTITION
-    // TODO(debargha) What are the correct values for these?
-    192, 192, 192
+  {252, 200}, {252, 200}, {252, 200},
 #endif  // CONFIG_EXT_PARTITION
 };
-#endif  // CONFIG_OBMC
+#endif  // CONFIG_OBMC || !CONFIG_WARPED_MOTION
 
 /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
 const vpx_tree_index vp10_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
@@ -1287,9 +1330,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
 #endif  // CONFIG_EXT_INTER
 #endif  // CONFIG_REF_MV
   vp10_copy(fc->inter_mode_probs, default_inter_mode_probs);
-#if CONFIG_OBMC
-  vp10_copy(fc->obmc_prob, default_obmc_prob);
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  vp10_copy(fc->motvar_prob, default_motvar_prob);
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 #if CONFIG_EXT_INTER
   vp10_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
   vp10_copy(fc->interintra_prob, default_interintra_prob);
@@ -1381,14 +1424,14 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
 #else
   for (i = 0; i < INTER_MODE_CONTEXTS; i++)
     vpx_tree_merge_probs(vp10_inter_mode_tree, pre_fc->inter_mode_probs[i],
-                counts->inter_mode[i], fc->inter_mode_probs[i]);
+                         counts->inter_mode[i], fc->inter_mode_probs[i]);
 #endif
 
-#if CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
   for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
-    fc->obmc_prob[i] = vp10_mode_mv_merge_probs(pre_fc->obmc_prob[i],
-                                                counts->obmc[i]);
-#endif  // CONFIG_OBMC
+    vpx_tree_merge_probs(vp10_motvar_tree, pre_fc->motvar_prob[i],
+                         counts->motvar[i], fc->motvar_prob[i]);
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 #if CONFIG_SUPERTX
   for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
index 42b93d644d8d6cc9b87d927f95d66dfb41898207..1c9f8691b5d468fdf3d02ac1e882194bfd1e0e33 100644 (file)
@@ -79,9 +79,9 @@ typedef struct frame_contexts {
   vpx_prob wedge_interintra_prob[BLOCK_SIZES];
   vpx_prob wedge_interinter_prob[BLOCK_SIZES];
 #endif  // CONFIG_EXT_INTER
-#if CONFIG_OBMC
-  vpx_prob obmc_prob[BLOCK_SIZES];
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  vpx_prob motvar_prob[BLOCK_SIZES][MOTION_VARIATIONS - 1];
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
   vpx_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
   vpx_prob comp_inter_prob[COMP_INTER_CONTEXTS];
   vpx_prob single_ref_prob[REF_CONTEXTS][SINGLE_REFS-1];
@@ -154,9 +154,9 @@ typedef struct FRAME_COUNTS {
   unsigned int wedge_interintra[BLOCK_SIZES][2];
   unsigned int wedge_interinter[BLOCK_SIZES][2];
 #endif  // CONFIG_EXT_INTER
-#if CONFIG_OBMC
-  unsigned int obmc[BLOCK_SIZES][2];
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  unsigned int motvar[BLOCK_SIZES][MOTION_VARIATIONS];
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
   unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
   unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
   unsigned int single_ref[REF_CONTEXTS][SINGLE_REFS-1][2];
@@ -242,6 +242,9 @@ extern const vpx_tree_index
 extern const vpx_tree_index
     vp10_ext_tx_tree[TREE_SIZE(TX_TYPES)];
 #endif  // CONFIG_EXT_TX
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+extern const vpx_tree_index vp10_motvar_tree[TREE_SIZE(MOTION_VARIATIONS)];
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 void vp10_setup_past_independence(struct VP10Common *cm);
 
index cdebc69a8ad06e22cd448b320e77c5c556f60340..3bcdb4ceaef458d8165d1fcd29da212138e928f8 100644 (file)
@@ -281,6 +281,17 @@ typedef uint8_t PREDICTION_MODE;
 
 #define INTRA_MODES (TM_PRED + 1)
 
+typedef enum {
+  SIMPLE_TRANSLATION = 0,
+#if CONFIG_OBMC
+  OBMC_CAUSAL,    // 2-sided OBMC
+#endif  // CONFIG_OBMC
+#if CONFIG_WARPED_MOTION
+  WARPED_CAUSAL,  // 2-sided WARPED
+#endif  // CONFIG_WARPED_MOTION
+  MOTION_VARIATIONS
+} MOTION_VARIATION;
+
 #if CONFIG_EXT_INTER
 typedef enum {
   II_DC_PRED = 0,
index a8278c455fbf6cbee619e07247f89777ade79f6a..1911c36a4545f9855c1450bba83c1d120144fd6f 100644 (file)
@@ -339,7 +339,6 @@ static const uint8_t *get_wedge_mask(int wedge_index,
   return wedge_params_lookup[bsize].masks[neg][wedge_index];
 }
 
-
 const uint8_t *vp10_get_soft_mask(int wedge_index,
                                   int wedge_sign,
                                   BLOCK_SIZE sb_type,
index 83d08b164611345c090d3c3ed91fdd27d34118fb..6615c23f0ac9596eae84e9f2688908266b5a1a1a 100644 (file)
@@ -1319,7 +1319,7 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd,
       vp10_build_inter_predictors_sb(xd, mi_row, mi_col,
                                      VPXMAX(bsize, BLOCK_8X8));
 #if CONFIG_OBMC
-      if (mbmi->obmc) {
+      if (mbmi->motion_variation == OBMC_CAUSAL) {
 #if CONFIG_VP9_HIGHBITDEPTH
         DECLARE_ALIGNED(16, uint8_t,
                         tmp_buf1[2 * MAX_MB_PLANE * MAX_SB_SQUARE]);
@@ -3544,10 +3544,12 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data,
     }
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_OBMC
-    for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
-      vp10_diff_update_prob(&r, &fc->obmc_prob[i]);
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+    for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i) {
+      for (j = 0; j < MOTION_VARIATIONS - 1; ++j)
+        vp10_diff_update_prob(&r, &fc->motvar_prob[i][j]);
+    }
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
     if (cm->interp_filter == SWITCHABLE)
       read_switchable_interp_probs(fc, &r);
@@ -3615,10 +3617,10 @@ static void debug_check_frame_counts(const VP10_COMMON *const cm) {
   assert(!memcmp(cm->counts.wedge_interinter, zero_counts.wedge_interinter,
                  sizeof(cm->counts.wedge_interinter)));
 #endif  // CONFIG_EXT_INTER
-#if CONFIG_OBMC
-  assert(!memcmp(cm->counts.obmc, zero_counts.obmc,
-                 sizeof(cm->counts.obmc)));
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  assert(!memcmp(cm->counts.motvar, zero_counts.motvar,
+                 sizeof(cm->counts.motvar)));
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
   assert(!memcmp(cm->counts.intra_inter, zero_counts.intra_inter,
                  sizeof(cm->counts.intra_inter)));
   assert(!memcmp(cm->counts.comp_inter, zero_counts.comp_inter,
index 033d9c0d99e68c22cade4492d307d0d2f2a849f4..4a669b1f1b0d04b140c4bde58f3582f17a014db5 100644 (file)
@@ -883,23 +883,24 @@ static void read_ref_frames(VP10_COMMON *const cm, MACROBLOCKD *const xd,
 }
 
 
-#if CONFIG_OBMC
-static int read_is_obmc_block(VP10_COMMON *const cm, MACROBLOCKD *const xd,
-                              vp10_reader *r) {
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+static MOTION_VARIATION read_motvar_block(
+    VP10_COMMON *const cm, MACROBLOCKD *const xd, vp10_reader *r) {
   BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
   FRAME_COUNTS *counts = xd->counts;
-  int is_obmc;
+  MOTION_VARIATION motvar;
 
-  if (is_obmc_allowed(&xd->mi[0]->mbmi)) {
-    is_obmc = vp10_read(r, cm->fc->obmc_prob[bsize]);
+  if (is_motvar_allowed(&xd->mi[0]->mbmi)) {
+    motvar = (MOTION_VARIATION)
+        vp10_read_tree(r, vp10_motvar_tree, cm->fc->motvar_prob[bsize]);
     if (counts)
-      ++counts->obmc[bsize][is_obmc];
-    return is_obmc;
+      ++counts->motvar[bsize][motvar];
+    return motvar;
   } else {
-    return 0;
+    return SIMPLE_TRANSLATION;
   }
 }
-#endif  // CONFIG_OBMC
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 static INLINE INTERP_FILTER read_interp_filter(
     VP10_COMMON *const cm, MACROBLOCKD *const xd,
@@ -1599,24 +1600,25 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
   }
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_OBMC
-  mbmi->obmc = 0;
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  mbmi->motion_variation = SIMPLE_TRANSLATION;
 #if CONFIG_SUPERTX
   if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
 #if CONFIG_EXT_INTER
     if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
-    mbmi->obmc = read_is_obmc_block(cm, xd, r);
-#endif  // CONFIG_OBMC
+    mbmi->motion_variation = read_motvar_block(cm, xd, r);
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
   mbmi->use_wedge_interinter = 0;
   if (cm->reference_mode != SINGLE_REFERENCE &&
       is_inter_compound_mode(mbmi->mode) &&
-#if CONFIG_OBMC
-      !(is_obmc_allowed(mbmi) && mbmi->obmc) &&
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+      !(is_motvar_allowed(mbmi) &&
+        mbmi->motion_variation != SIMPLE_TRANSLATION) &&
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
       is_interinter_wedge_used(bsize)) {
     mbmi->use_wedge_interinter =
         vp10_read(r, cm->fc->wedge_interinter_prob[bsize]);
index fb877674bcbb44391323dafb9adcb2d778e0c2b6..975778298f946c99e248f869ba09a42ab890bcad 100644 (file)
@@ -117,6 +117,9 @@ static struct vp10_token intra_filter_encodings[INTRA_FILTERS];
 #if CONFIG_EXT_INTER
 static struct vp10_token interintra_mode_encodings[INTERINTRA_MODES];
 #endif  // CONFIG_EXT_INTER
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+static struct vp10_token motvar_encodings[MOTION_VARIATIONS];
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 void vp10_encode_token_init() {
 #if CONFIG_EXT_TX
@@ -136,6 +139,9 @@ void vp10_encode_token_init() {
 #if CONFIG_EXT_INTER
   vp10_tokens_from_tree(interintra_mode_encodings, vp10_interintra_mode_tree);
 #endif  // CONFIG_EXT_INTER
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  vp10_tokens_from_tree(motvar_encodings, vp10_motvar_tree);
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 }
 
 static void write_intra_mode(vp10_writer *w, PREDICTION_MODE mode,
@@ -1370,22 +1376,24 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi,
     }
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
 #if CONFIG_SUPERTX
     if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
 #if CONFIG_EXT_INTER
       if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
-      if (is_obmc_allowed(mbmi))
-        vp10_write(w, mbmi->obmc, cm->fc->obmc_prob[bsize]);
-#endif  // CONFIG_OBMC
+      if (is_motvar_allowed(mbmi))
+        vp10_write_token(w, vp10_motvar_tree, cm->fc->motvar_prob[bsize],
+                         &motvar_encodings[mbmi->motion_variation]);
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
     if (cpi->common.reference_mode != SINGLE_REFERENCE &&
         is_inter_compound_mode(mbmi->mode) &&
 #if CONFIG_OBMC
-        !(is_obmc_allowed(mbmi) && mbmi->obmc) &&
+        !(is_motvar_allowed(mbmi) &&
+          mbmi->motion_variation != SIMPLE_TRANSLATION) &&
 #endif  // CONFIG_OBMC
         is_interinter_wedge_used(bsize)) {
       vp10_write(w, mbmi->use_wedge_interinter,
@@ -3283,11 +3291,11 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) {
     }
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
     for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
-      vp10_cond_prob_diff_update(header_bc, &fc->obmc_prob[i],
-                                 counts->obmc[i]);
-#endif  // CONFIG_OBMC
+      prob_diff_update(vp10_motvar_tree, fc->motvar_prob[i],
+                       counts->motvar[i], MOTION_VARIATIONS, header_bc);
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
     if (cm->interp_filter == SWITCHABLE)
       update_switchable_interp_probs(cm, header_bc, counts);
index 39b0d8e2ead48b4ece5d77ba729a989cf156d620..4fcbbeeae5585dc275ec66e87e2ddfe8081319ea 100644 (file)
@@ -1337,10 +1337,8 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td,
         mbmi->inter_tx_size[idy][idx] = mbmi->tx_size;
   }
 #endif  // CONFIG_VAR_TX
-#if CONFIG_OBMC
-  // Turn OBMC off for supertx
-  mbmi->obmc = 0;
-#endif  // CONFIG_OBMC
+  // Turn motion variation off for supertx
+  mbmi->motion_variation = SIMPLE_TRANSLATION;
 
   if (!output_enabled)
     return;
@@ -1966,23 +1964,24 @@ static void update_stats(VP10_COMMON *cm, ThreadData *td
     }
 #endif  // CONFIG_EXT_INTER
 
-#if CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
 #if CONFIG_SUPERTX
         if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
 #if CONFIG_EXT_INTER
         if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
-          if (is_obmc_allowed(mbmi))
-            counts->obmc[mbmi->sb_type][mbmi->obmc]++;
-#endif  // CONFIG_OBMC
+          if (is_motvar_allowed(mbmi))
+            counts->motvar[mbmi->sb_type][mbmi->motion_variation]++;
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
         if (cm->reference_mode != SINGLE_REFERENCE &&
             is_inter_compound_mode(mbmi->mode) &&
-#if CONFIG_OBMC
-            !(is_obmc_allowed(mbmi) && mbmi->obmc) &&
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+            !(is_motvar_allowed(mbmi) &&
+              mbmi->motion_variation != SIMPLE_TRANSLATION) &&
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
             is_interinter_wedge_used(bsize)) {
           counts->wedge_interinter[bsize][mbmi->use_wedge_interinter]++;
         }
@@ -5034,7 +5033,7 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
                                      VPXMAX(bsize, BLOCK_8X8));
 
 #if CONFIG_OBMC
-    if (mbmi->obmc) {
+    if (mbmi->motion_variation == OBMC_CAUSAL) {
 #if CONFIG_VP9_HIGHBITDEPTH
       DECLARE_ALIGNED(16, uint8_t, tmp_buf1[2 * MAX_MB_PLANE * MAX_SB_SQUARE]);
       DECLARE_ALIGNED(16, uint8_t, tmp_buf2[2 * MAX_MB_PLANE * MAX_SB_SQUARE]);
index 7b7bd7d52812c231745addca412b1173979b2be1..ab0fbe9e803bc1cd9d6b0e401ca45fbac48e4911 100644 (file)
@@ -527,9 +527,9 @@ typedef struct VP10_COMP {
                                        [INTER_COMPOUND_MODES];
   unsigned int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES];
 #endif  // CONFIG_EXT_INTER
-#if CONFIG_OBMC
-  int obmc_cost[BLOCK_SIZES][2];
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  int motvar_cost[BLOCK_SIZES][MOTION_VARIATIONS];
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
   int intra_uv_mode_cost[INTRA_MODES][INTRA_MODES];
   int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
   int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
index f7128b11b20c2b2e3c0336067d0664db144e1855..33cca3855dd705e0dde5432d6f8c796efd9ef29e 100644 (file)
@@ -472,12 +472,12 @@ void vp10_initialize_rd_consts(VP10_COMP *cpi) {
                          cm->fc->interintra_mode_prob[i],
                          vp10_interintra_mode_tree);
 #endif  // CONFIG_EXT_INTER
-#if CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
       for (i = BLOCK_8X8; i < BLOCK_SIZES; i++) {
-        cpi->obmc_cost[i][0] = vp10_cost_bit(cm->fc->obmc_prob[i], 0);
-        cpi->obmc_cost[i][1] = vp10_cost_bit(cm->fc->obmc_prob[i], 1);
+        vp10_cost_tokens((int *)cpi->motvar_cost[i],
+                         cm->fc->motvar_prob[i], vp10_motvar_tree);
       }
-#endif  // CONFIG_OBMC
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
     }
   }
 }
index a1b4fb7a4a1a8929e098ed9fedd4291c25892821..5df08b82f1bfbc99dd2bd8e975edc2574ff7a8de 100644 (file)
@@ -6947,12 +6947,12 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
 #endif  // CONFIG_VP9_HIGHBITDEPTH
   uint8_t *tmp_buf;
 
-#if CONFIG_OBMC
-  int allow_obmc =
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+  int allow_motvar =
 #if CONFIG_EXT_INTER
       !is_comp_interintra_pred &&
 #endif  // CONFIG_EXT_INTER
-      is_obmc_allowed(mbmi);
+      is_motvar_allowed(mbmi);
   int rate2_nocoeff, best_rate2 = INT_MAX,
       best_skippable, best_xskip, best_disable_skip = 0;
 #if CONFIG_SUPERTX
@@ -6969,7 +6969,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
   int rate_mv_bmc;
   MB_MODE_INFO best_bmc_mbmi;
 #endif  // CONFIG_EXT_INTER
-#endif  // CONFIG_OBMC
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
   int pred_exists = 0;
   int intpel_mv;
@@ -7864,13 +7864,17 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
   memcpy(x->skip_txfm, skip_txfm, sizeof(skip_txfm));
   memcpy(x->bsse, bsse, sizeof(bsse));
 
-#if CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
   best_rd = INT64_MAX;
-  for (mbmi->obmc = 0; mbmi->obmc <= allow_obmc; mbmi->obmc++) {
+  for (mbmi->motion_variation = SIMPLE_TRANSLATION;
+       mbmi->motion_variation < (allow_motvar ? MOTION_VARIATIONS : 1);
+       mbmi->motion_variation++) {
     int64_t tmp_rd, tmp_dist;
     int tmp_rate;
 #if CONFIG_EXT_INTER
-    int tmp_rate2 = mbmi->obmc ? rate2_bmc_nocoeff : rate2_nocoeff;
+    int tmp_rate2 =
+        mbmi->motion_variation != SIMPLE_TRANSLATION ?
+        rate2_bmc_nocoeff : rate2_nocoeff;
 #else
     int tmp_rate2 = rate2_nocoeff;
 #endif  // CONFIG_EXT_INTER
@@ -7888,10 +7892,11 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
 #endif  // CONFIG_DUAL_FILTER
 #endif  // CONFIG_EXT_INTERP
 
-    if (mbmi->obmc) {
+#if CONFIG_OBMC
+    if (mbmi->motion_variation == OBMC_CAUSAL) {
 #if CONFIG_EXT_INTER
       *mbmi = best_bmc_mbmi;
-      mbmi->obmc = 1;
+      mbmi->motion_variation = OBMC_CAUSAL;
 #endif  // CONFIG_EXT_INTER
       if (!is_comp_pred && have_newmv_in_inter_mode(this_mode)) {
         int_mv tmp_mv;
@@ -7943,13 +7948,22 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
       model_rd_for_sb(cpi, bsize, x, xd, 0, MAX_MB_PLANE - 1,
                       &tmp_rate, &tmp_dist, &skip_txfm_sb, &skip_sse_sb);
     }
+#endif  // CONFIG_OBMC
+
+#if CONFIG_WARPED_MOTION
+    if (mbmi->motion_variation == WARPED_CAUSAL) {
+      // TODO(yuec): Add code
+    }
+#endif  // CONFIG_WARPED_MOTION
+
 #if CONFIG_VP9_HIGHBITDEPTH
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-      x->pred_variance = vp10_high_get_sby_perpixel_variance(cpi,
-                                              &xd->plane[0].dst, bsize, xd->bd);
+      x->pred_variance =
+          vp10_high_get_sby_perpixel_variance(
+              cpi, &xd->plane[0].dst, bsize, xd->bd);
     } else {
       x->pred_variance =
-        vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize);
+          vp10_get_sby_perpixel_variance(cpi, &xd->plane[0].dst, bsize);
     }
 #else
     x->pred_variance =
@@ -7958,124 +7972,128 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
     x->skip = 0;
 
     *rate2 = tmp_rate2;
-    if (allow_obmc)
-      *rate2 += cpi->obmc_cost[bsize][mbmi->obmc];
+    if (allow_motvar)
+      *rate2 += cpi->motvar_cost[bsize][mbmi->motion_variation];
     *distortion = 0;
-#endif  // CONFIG_OBMC
-  if (!skip_txfm_sb) {
-    int skippable_y, skippable_uv;
-    int64_t sseuv = INT64_MAX;
-    int64_t rdcosty = INT64_MAX;
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
+    if (!skip_txfm_sb) {
+      int skippable_y, skippable_uv;
+      int64_t sseuv = INT64_MAX;
+      int64_t rdcosty = INT64_MAX;
 
-    // Y cost and distortion
-    vp10_subtract_plane(x, bsize, 0);
+      // Y cost and distortion
+      vp10_subtract_plane(x, bsize, 0);
 #if CONFIG_VAR_TX
-    if (cm->tx_mode == TX_MODE_SELECT || xd->lossless[mbmi->segment_id]) {
-      select_tx_type_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse,
-                         bsize, ref_best_rd);
-    } else {
-      int idx, idy;
+      if (cm->tx_mode == TX_MODE_SELECT || xd->lossless[mbmi->segment_id]) {
+        select_tx_type_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse,
+                           bsize, ref_best_rd);
+      } else {
+        int idx, idy;
+        super_block_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse,
+                        bsize, ref_best_rd);
+        for (idy = 0; idy < xd->n8_h; ++idy)
+          for (idx = 0; idx < xd->n8_w; ++idx)
+            mbmi->inter_tx_size[idy][idx] = mbmi->tx_size;
+        memset(x->blk_skip[0], skippable_y,
+               sizeof(uint8_t) * xd->n8_h * xd->n8_w * 4);
+      }
+#else
       super_block_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse,
                       bsize, ref_best_rd);
-      for (idy = 0; idy < xd->n8_h; ++idy)
-        for (idx = 0; idx < xd->n8_w; ++idx)
-          mbmi->inter_tx_size[idy][idx] = mbmi->tx_size;
-      memset(x->blk_skip[0], skippable_y,
-             sizeof(uint8_t) * xd->n8_h * xd->n8_w * 4);
-    }
-#else
-    super_block_yrd(cpi, x, rate_y, &distortion_y, &skippable_y, psse,
-                    bsize, ref_best_rd);
 #endif  // CONFIG_VAR_TX
 
-    if (*rate_y == INT_MAX) {
-      *rate2 = INT_MAX;
-      *distortion = INT64_MAX;
-#if CONFIG_OBMC
-      if (mbmi->obmc) {
-        continue;
-      } else {
-#endif  // CONFIG_OBMC
-      restore_dst_buf(xd, orig_dst, orig_dst_stride);
-      return INT64_MAX;
-#if CONFIG_OBMC
+      if (*rate_y == INT_MAX) {
+        *rate2 = INT_MAX;
+        *distortion = INT64_MAX;
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+        if (mbmi->motion_variation != SIMPLE_TRANSLATION) {
+          continue;
+        } else {
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
+          restore_dst_buf(xd, orig_dst, orig_dst_stride);
+          return INT64_MAX;
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+        }
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
       }
-#endif  // CONFIG_OBMC
-    }
 
-    *rate2 += *rate_y;
-    *distortion += distortion_y;
+      *rate2 += *rate_y;
+      *distortion += distortion_y;
 
-    rdcosty = RDCOST(x->rdmult, x->rddiv, *rate2, *distortion);
-    rdcosty = VPXMIN(rdcosty, RDCOST(x->rdmult, x->rddiv, 0, *psse));
+      rdcosty = RDCOST(x->rdmult, x->rddiv, *rate2, *distortion);
+      rdcosty = VPXMIN(rdcosty, RDCOST(x->rdmult, x->rddiv, 0, *psse));
 
 #if CONFIG_VAR_TX
-    if (!inter_block_uvrd(cpi, x, rate_uv, &distortion_uv, &skippable_uv,
-                          &sseuv, bsize, ref_best_rd - rdcosty)) {
+      if (!inter_block_uvrd(cpi, x, rate_uv, &distortion_uv, &skippable_uv,
+                            &sseuv, bsize, ref_best_rd - rdcosty))
 #else
-    if (!super_block_uvrd(cpi, x, rate_uv, &distortion_uv, &skippable_uv,
-                          &sseuv, bsize, ref_best_rd - rdcosty)) {
+      if (!super_block_uvrd(cpi, x, rate_uv, &distortion_uv, &skippable_uv,
+                            &sseuv, bsize, ref_best_rd - rdcosty))
 #endif  // CONFIG_VAR_TX
-      *rate2 = INT_MAX;
-      *distortion = INT64_MAX;
-#if CONFIG_OBMC
-      continue;
+      {
+        *rate2 = INT_MAX;
+        *distortion = INT64_MAX;
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+        continue;
 #else
-      restore_dst_buf(xd, orig_dst, orig_dst_stride);
-      return INT64_MAX;
-#endif  // CONFIG_OBMC
-    }
+        restore_dst_buf(xd, orig_dst, orig_dst_stride);
+        return INT64_MAX;
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
+      }
 
-    *psse += sseuv;
-    *rate2 += *rate_uv;
-    *distortion += distortion_uv;
-    *skippable = skippable_y && skippable_uv;
-#if CONFIG_OBMC
-    if (*skippable) {
-      *rate2 -= *rate_uv + *rate_y;
-      *rate_y = 0;
-      *rate_uv = 0;
-      *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1);
-      mbmi->skip = 0;
-      // here mbmi->skip temporarily plays a role as what this_skip2 does
-    } else if (!xd->lossless[mbmi->segment_id] &&
-               (RDCOST(x->rdmult, x->rddiv, *rate_y + *rate_uv +
-                  vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0), *distortion) >=
-                RDCOST(x->rdmult, x->rddiv,
-                  vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1), *psse))) {
-      *rate2 -= *rate_uv + *rate_y;
-      *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1);
-      *distortion = *psse;
-      *rate_y = 0;
-      *rate_uv = 0;
-      mbmi->skip = 1;
+      *psse += sseuv;
+      *rate2 += *rate_uv;
+      *distortion += distortion_uv;
+      *skippable = skippable_y && skippable_uv;
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+      if (*skippable) {
+        *rate2 -= *rate_uv + *rate_y;
+        *rate_y = 0;
+        *rate_uv = 0;
+        *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1);
+        mbmi->skip = 0;
+        // here mbmi->skip temporarily plays a role as what this_skip2 does
+      } else if (!xd->lossless[mbmi->segment_id] &&
+                 (RDCOST(x->rdmult, x->rddiv, *rate_y + *rate_uv +
+                         vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0),
+                         *distortion) >=
+                  RDCOST(x->rdmult, x->rddiv,
+                         vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1),
+                         *psse))) {
+        *rate2 -= *rate_uv + *rate_y;
+        *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1);
+        *distortion = *psse;
+        *rate_y = 0;
+        *rate_uv = 0;
+        mbmi->skip = 1;
+      } else {
+        *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0);
+        mbmi->skip = 0;
+      }
+      *disable_skip = 0;
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
     } else {
-      *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0);
+      x->skip = 1;
+      *disable_skip = 1;
+
+      // The cost of skip bit needs to be added.
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
       mbmi->skip = 0;
-    }
-    *disable_skip = 0;
-#endif  // CONFIG_OBMC
-  } else {
-    x->skip = 1;
-    *disable_skip = 1;
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
+      *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1);
 
-    // The cost of skip bit needs to be added.
-#if CONFIG_OBMC
-    mbmi->skip = 0;
-#endif  // CONFIG_OBMC
-    *rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1);
+      *distortion = skip_sse_sb;
+    }
 
-    *distortion = skip_sse_sb;
-  }
-#if CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
     tmp_rd = RDCOST(x->rdmult, x->rddiv, *rate2, *distortion);
-    if (mbmi->obmc == 0 || (tmp_rd < best_rd)) {
+    if (mbmi->motion_variation == SIMPLE_TRANSLATION || (tmp_rd < best_rd)) {
 #if CONFIG_EXT_INTERP
 #if CONFIG_DUAL_FILTER
-      mbmi->interp_filter[0] = obmc_interp_filter[mbmi->obmc][0];
-      mbmi->interp_filter[1] = obmc_interp_filter[mbmi->obmc][1];
+      mbmi->interp_filter[0] = obmc_interp_filter[mbmi->motion_variation][0];
+      mbmi->interp_filter[1] = obmc_interp_filter[mbmi->motion_variation][1];
 #else
-      mbmi->interp_filter = obmc_interp_filter[mbmi->obmc];
+      mbmi->interp_filter = obmc_interp_filter[mbmi->motion_variation];
 #endif  // CONFIG_DUAL_FILTER
 #endif  // CONFIG_EXT_INTERP
       best_mbmi = *mbmi;
@@ -8120,7 +8138,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
   x->skip = best_xskip;
   *disable_skip = best_disable_skip;
   x->pred_variance = best_pred_var;
-#endif  // CONFIG_OBMC
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 
   if (!is_comp_pred)
     single_skippable[this_mode][refs[0]] = *skippable;
@@ -8952,9 +8970,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
                                                           : cm->interp_filter;
 #endif
     mbmi->mv[0].as_int = mbmi->mv[1].as_int = 0;
-#if CONFIG_OBMC
-    mbmi->obmc = 0;
-#endif  // CONFIG_OBMC
+    mbmi->motion_variation = SIMPLE_TRANSLATION;
 
     x->skip = 0;
     set_ref_ptrs(cm, xd, ref_frame, second_ref_frame);
@@ -9386,10 +9402,10 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
 #if CONFIG_EXT_INTER
     rate2 += compmode_interintra_cost;
     if (cm->reference_mode != SINGLE_REFERENCE && comp_pred)
-#if CONFIG_OBMC
-      if (mbmi->obmc == 0)
-#endif  // CONFIG_OBMC
-      rate2 += compmode_wedge_cost;
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+      if (mbmi->motion_variation == SIMPLE_TRANSLATION)
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
+        rate2 += compmode_wedge_cost;
 #endif  // CONFIG_EXT_INTER
 
     // Estimate the reference frame signaling cost and add it
@@ -9492,10 +9508,10 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
             disable_skip || skippable || this_skip2);
         *returnrate_nocoef -= vp10_cost_bit(vp10_get_intra_inter_prob(cm, xd),
                                             mbmi->ref_frame[0] != INTRA_FRAME);
-#if CONFIG_OBMC
-        if (is_inter_block(mbmi) && is_obmc_allowed(mbmi))
-          *returnrate_nocoef -= cpi->obmc_cost[bsize][mbmi->obmc];
-#endif  // CONFIG_OBMC
+#if CONFIG_OBMC || CONFIG_WARPED_MOTION
+        if (is_inter_block(mbmi) && is_motvar_allowed(mbmi))
+          *returnrate_nocoef -= cpi->motvar_cost[bsize][mbmi->motion_variation];
+#endif  // CONFIG_OBMC || CONFIG_WARPED_MOTION
 #endif  // CONFIG_SUPERTX
         rd_cost->dist = distortion2;
         rd_cost->rdcost = this_rd;
@@ -10219,9 +10235,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi,
   mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0;
   mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0;
 #endif  // CONFIG_EXT_INTRA
-#if CONFIG_OBMC
-  mbmi->obmc = 0;
-#endif  // CONFIG_OBMC
+  mbmi->motion_variation = SIMPLE_TRANSLATION;
 #if CONFIG_EXT_INTER
   mbmi->use_wedge_interinter = 0;
   mbmi->use_wedge_interintra = 0;