Allow updates of motion costs for intrabc

This commits enables the encoder to update the motion vector table for
intrabc at various resolutions. By default, this is turned on for good
mode, but is disabled for realtime mode and allintra mode.

The IntraBCMVCosts struct is moved from AV1_COMP to MACROBLOCK to
support multithreading.

Performance on screen_content set:

 SPD_SET | AVG_PSNR | OVR_PSNR |   SSIM  |  SPD
    1    |  -0.166% |  -0.209% | -0.107% | +0.1%
    2    |  -0.284% |  -0.298% | -0.415% | +0.0%
    3    |  -0.229% |  -0.238% | -0.282% | +0.1%
    4    |  -0.368% |  -0.172% | -0.554% | -0.3%
    5    |  -0.274% |  -0.267% | -0.413% | -0.1%
    6    |  -0.338% |  -0.348% | -0.357% | +0.2%

STATS_CHANGED

Change-Id: I1aec9cc1a4eb06d1806d71df9dba1defad9a7e1d
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 123bb1d..110e902 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -916,6 +916,8 @@
   oxcf->cost_upd_freq.coeff = (COST_UPDATE_TYPE)extra_cfg->coeff_cost_upd_freq;
   oxcf->cost_upd_freq.mode = (COST_UPDATE_TYPE)extra_cfg->mode_cost_upd_freq;
   oxcf->cost_upd_freq.mv = (COST_UPDATE_TYPE)extra_cfg->mv_cost_upd_freq;
+  // TODO(chiyotsai@google.com): Add command line support in a separate cl.
+  oxcf->cost_upd_freq.dv = COST_UPD_SB;
 
   // Set frame resize mode configuration.
   resize_cfg->resize_mode = (RESIZE_MODE)cfg->rc_resize_mode;
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 59353cf..56ee891 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -778,6 +778,23 @@
   /**@}*/
 } MvCosts;
 
+/*! \brief Holds mv costs for intrabc.
+ */
+typedef struct {
+  /*! Costs for coding the joint mv. */
+  int joint_mv[MV_JOINTS];
+
+  /*! \brief Cost of transmitting the actual motion vector.
+   *  mv_costs_alloc[0][i] is the cost of motion vector with horizontal
+   * component (mv_row) equal to i - MV_MAX. mv_costs_alloc[1][i] is the cost of
+   * motion vector with vertical component (mv_col) equal to i - MV_MAX.
+   */
+  int dv_costs_alloc[2][MV_VALS];
+
+  /*! Points to the middle of \ref dv_costs_alloc. */
+  int *dv_costs[2];
+} IntraBCMVCosts;
+
 /*! \brief Holds the costs needed to encode the coefficients
  */
 typedef struct {
@@ -945,6 +962,11 @@
   //! multipliers for motion search.
   MvCosts *mv_costs;
 
+  /*! The rate needed to encode a new motion vector to the bitstream in intrabc
+   *  mode.
+   */
+  IntraBCMVCosts *dv_costs;
+
   //! The rate needed to signal the txfm coefficients to the bitstream.
   CoeffCosts coeff_costs;
   /**@}*/
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 24d3488..515081d 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -753,7 +753,8 @@
 static AOM_INLINE int is_rtc_mode(const CostUpdateFreq *cost_upd_freq,
                                   int use_non_rd_mode) {
   return (use_non_rd_mode && cost_upd_freq->coeff >= 2 &&
-          cost_upd_freq->mode >= 2 && cost_upd_freq->mv >= 2);
+          cost_upd_freq->mode >= 2 && cost_upd_freq->mv >= 2 &&
+          cost_upd_freq->dv >= 2);
 }
 
 /*!\brief Encode a superblock row by breaking it into superblocks
diff --git a/av1/encoder/encodeframe_utils.c b/av1/encoder/encodeframe_utils.c
index c10b2ff..8ded505 100644
--- a/av1/encoder/encodeframe_utils.c
+++ b/av1/encoder/encodeframe_utils.c
@@ -1294,29 +1294,29 @@
 #endif  // CONFIG_INTERNAL_STATS
 }
 
-// Checks for skip status of mv cost update.
-static int skip_mv_cost_update(AV1_COMP *cpi, const TileInfo *const tile_info,
-                               const int mi_row, const int mi_col) {
-  // For intra frames, mv cdfs are not updated during the encode. Hence, the mv
-  // cost calculation is skipped in this case.
-  if (frame_is_intra_only(&cpi->common)) return 1;
-  // mv_cost_upd_level=0: update happens at each sb,
-  //                      so return skip status as 0.
-  // mv_cost_upd_level=1: update happens once for each sb row,
-  //                      so return skip status as 1 for
-  //                      mi_col != tile_info->mi_col_start.
-  // mv_cost_upd_level=2: update happens once for a set of rows,
+static int skip_cost_update(const SequenceHeader *seq_params,
+                            const TileInfo *const tile_info, const int mi_row,
+                            const int mi_col, int upd_level) {
+  // upd_level=0: update happens at each sb,
+  //              so return skip status as 0.
+  // upd_level=1: update happens once for each sb row,
+  //              so return skip status as 1 for
+  //              mi_col != tile_info->mi_col_start.
+  // upd_level=2: update happens once for a set of rows,
   //                      so return skip status as 1 appropriately.
-  if (!cpi->sf.inter_sf.mv_cost_upd_level) return 0;
+  // upd_level=3: don't update, so return 1 immediately.
+  if (!upd_level) return 0;
   if (mi_col != tile_info->mi_col_start) return 1;
-  if (cpi->sf.inter_sf.mv_cost_upd_level == 2) {
-    AV1_COMMON *const cm = &cpi->common;
-    const int mib_size_log2 = cm->seq_params.mib_size_log2;
+  if (upd_level == 3) {
+    return 1;
+  }
+  if (upd_level == 2) {
+    const int mib_size_log2 = seq_params->mib_size_log2;
     const int sb_row = (mi_row - tile_info->mi_row_start) >> mib_size_log2;
-    const int sb_size = cm->seq_params.mib_size * MI_SIZE;
+    const int sb_size = seq_params->mib_size * MI_SIZE;
     const int tile_height =
         (tile_info->mi_row_end - tile_info->mi_row_start) * MI_SIZE;
-    // When mv_cost_upd_level = 2, the cost update happens once for 2, 4 sb
+    // When upd_level = 2, the cost update happens once for 2, 4 sb
     // rows for sb size 128, sb size 64 respectively. However, as the update
     // will not be equally spaced in smaller resolutions making it equally
     // spaced by calculating (mv_num_rows_cost_update) the number of rows
@@ -1337,6 +1337,32 @@
   return 0;
 }
 
+// Checks for skip status of mv cost update.
+static int skip_mv_cost_update(AV1_COMP *cpi, const TileInfo *const tile_info,
+                               const int mi_row, const int mi_col) {
+  const AV1_COMMON *cm = &cpi->common;
+  // For intra frames, mv cdfs are not updated during the encode. Hence, the mv
+  // cost calculation is skipped in this case.
+  if (frame_is_intra_only(cm)) return 1;
+
+  return skip_cost_update(&cm->seq_params, tile_info, mi_row, mi_col,
+                          cpi->sf.inter_sf.mv_cost_upd_level);
+}
+
+// Checks for skip status of dv cost update.
+static int skip_dv_cost_update(AV1_COMP *cpi, const TileInfo *const tile_info,
+                               const int mi_row, const int mi_col) {
+  const AV1_COMMON *cm = &cpi->common;
+  // Intrabc is only applicable to intra frames. So skip if current frame isn't
+  // intra frame.
+  if (!av1_allow_intrabc(cm) || is_stat_generation_stage(cpi)) {
+    return 1;
+  }
+
+  return skip_cost_update(&cm->seq_params, tile_info, mi_row, mi_col,
+                          cpi->sf.intra_sf.dv_cost_upd_level);
+}
+
 // Update the rate costs of some symbols according to the frequency directed
 // by speed features
 void av1_set_cost_upd_freq(AV1_COMP *cpi, ThreadData *td,
@@ -1388,4 +1414,19 @@
       break;
     default: assert(0);
   }
+
+  switch (cpi->oxcf.cost_upd_freq.dv) {
+    case COST_UPD_OFF:
+    case COST_UPD_TILE:  // Tile level
+      break;
+    case COST_UPD_SBROW:  // SB row level in tile
+      if (mi_col != tile_info->mi_col_start) break;
+      AOM_FALLTHROUGH_INTENDED;
+    case COST_UPD_SB:  // SB level
+      // Checks for skip status of dv cost update.
+      if (skip_dv_cost_update(cpi, tile_info, mi_row, mi_col)) break;
+      av1_fill_dv_costs(x->dv_costs, &xd->tile_ctx->ndvc);
+      break;
+    default: assert(0);
+  }
 }
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 905470f..34c2987 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -623,6 +623,8 @@
   COST_UPDATE_TYPE mode;
   // Indicates the update frequency for mv costs.
   COST_UPDATE_TYPE mv;
+  // Indicates the update frequency for dv costs.
+  COST_UPDATE_TYPE dv;
 } CostUpdateFreq;
 
 typedef struct {
@@ -2502,11 +2504,6 @@
   int intrabc_used;
 
   /*!
-   * Tables to calculate IntraBC MV cost.
-   */
-  IntraBCMVCosts dv_costs;
-
-  /*!
    * Mark which ref frames can be skipped for encoding current frame during RDO.
    */
   int prune_ref_frame_mask;
diff --git a/av1/encoder/encoder_alloc.h b/av1/encoder/encoder_alloc.h
index eae34e0..57ab2f2 100644
--- a/av1/encoder/encoder_alloc.h
+++ b/av1/encoder/encoder_alloc.h
@@ -78,6 +78,13 @@
   CHECK_MEM_ERROR(cm, cpi->td.mb.mv_costs,
                   (MvCosts *)aom_calloc(1, sizeof(MvCosts)));
 
+  if (cpi->td.mb.dv_costs) {
+    aom_free(cpi->td.mb.dv_costs);
+    cpi->td.mb.dv_costs = NULL;
+  }
+  CHECK_MEM_ERROR(cm, cpi->td.mb.dv_costs,
+                  (IntraBCMVCosts *)aom_malloc(sizeof(*cpi->td.mb.dv_costs)));
+
   av1_setup_shared_coeff_buffer(&cpi->common, &cpi->td.shared_coeff_buf);
   av1_setup_sms_tree(cpi, &cpi->td);
   cpi->td.firstpass_ctx =
@@ -215,6 +222,11 @@
     cpi->td.mb.mv_costs = NULL;
   }
 
+  if (cpi->td.mb.dv_costs) {
+    aom_free(cpi->td.mb.dv_costs);
+    cpi->td.mb.dv_costs = NULL;
+  }
+
   aom_free(cpi->td.mb.inter_modes_info);
   cpi->td.mb.inter_modes_info = NULL;
 
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 3735ca3..34dcc44 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -788,6 +788,10 @@
         cpi->oxcf.cost_upd_freq.mv < COST_UPD_OFF) {
       aom_free(thread_data->td->mb.mv_costs);
     }
+    if (thread_data->td != &cpi->td &&
+        cpi->oxcf.cost_upd_freq.dv < COST_UPD_OFF) {
+      aom_free(thread_data->td->mb.dv_costs);
+    }
 
     // Accumulate counters.
     if (i > 0) {
@@ -846,6 +850,13 @@
         memcpy(thread_data->td->mb.mv_costs, cpi->td.mb.mv_costs,
                sizeof(MvCosts));
       }
+      if (cpi->oxcf.cost_upd_freq.dv < COST_UPD_OFF) {
+        CHECK_MEM_ERROR(cm, thread_data->td->mb.dv_costs,
+                        (IntraBCMVCosts *)aom_malloc(
+                            sizeof(*thread_data->td->mb.dv_costs)));
+        memcpy(thread_data->td->mb.dv_costs, cpi->td.mb.dv_costs,
+               sizeof(*thread_data->td->mb.dv_costs));
+      }
     }
     // Reset cyclic refresh counters.
     av1_init_cyclic_refresh_counters(&thread_data->td->mb);
@@ -904,6 +915,13 @@
         memcpy(thread_data->td->mb.mv_costs, cpi->td.mb.mv_costs,
                sizeof(MvCosts));
       }
+      if (cpi->oxcf.cost_upd_freq.dv < COST_UPD_OFF) {
+        CHECK_MEM_ERROR(cm, thread_data->td->mb.dv_costs,
+                        (IntraBCMVCosts *)aom_malloc(
+                            sizeof(*thread_data->td->mb.dv_costs)));
+        memcpy(thread_data->td->mb.dv_costs, cpi->td.mb.dv_costs,
+               sizeof(*thread_data->td->mb.dv_costs));
+      }
     }
     if (!cpi->sf.rt_sf.use_nonrd_pick_mode) {
       CHECK_MEM_ERROR(cm, thread_data->td->mb.txfm_search_info.txb_rd_records,
@@ -1195,6 +1213,10 @@
         cpi->oxcf.cost_upd_freq.mv < COST_UPD_OFF) {
       aom_free(thread_data->td->mb.mv_costs);
     }
+    if (thread_data->td != &cpi->td &&
+        cpi->oxcf.cost_upd_freq.dv < COST_UPD_OFF) {
+      aom_free(thread_data->td->mb.dv_costs);
+    }
     if (thread_data->td->mb.txfm_search_info.txb_rd_records) {
       aom_free(thread_data->td->mb.txfm_search_info.txb_rd_records);
     }
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 06f9386..5083084 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -145,8 +145,8 @@
   MV_COST_PARAMS *mv_cost_params = &ms_params->mv_cost_params;
 
   mv_cost_params->mvjcost = dv_costs->joint_mv;
-  mv_cost_params->mvcost[0] = &dv_costs->mv_component[0][MV_MAX];
-  mv_cost_params->mvcost[1] = &dv_costs->mv_component[1][MV_MAX];
+  mv_cost_params->mvcost[0] = dv_costs->dv_costs[0];
+  mv_cost_params->mvcost[1] = dv_costs->dv_costs[1];
 }
 
 void av1_make_default_subpel_ms_params(SUBPEL_MOTION_SEARCH_PARAMS *ms_params,
@@ -253,7 +253,7 @@
 // nearest 2 ** 7.
 // This is NOT used during motion compensation.
 int av1_mv_bit_cost(const MV *mv, const MV *ref_mv, const int *mvjcost,
-                    int *mvcost[2], int weight) {
+                    int *const mvcost[2], int weight) {
   const MV diff = { mv->row - ref_mv->row, mv->col - ref_mv->col };
   return ROUND_POWER_OF_TWO(
       mv_cost(&diff, mvjcost, CONVERT_TO_CONST_MVCOST(mvcost)) * weight, 7);
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index 901671e..b2539f5 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -84,7 +84,7 @@
 } MV_COST_PARAMS;
 
 int av1_mv_bit_cost(const MV *mv, const MV *ref_mv, const int *mvjcost,
-                    int *mvcost[2], int weight);
+                    int *const mvcost[2], int weight);
 
 int av1_get_mvpred_sse(const MV_COST_PARAMS *mv_cost_params,
                        const FULLPEL_MV best_mv,
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index 5d54a80..122a12d 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -798,10 +798,16 @@
   }
 
   if (av1_allow_intrabc(cm)) {
-    update_cdf(fc->intrabc_cdf, is_intrabc_block(mbmi), 2);
+    const int is_intrabc = is_intrabc_block(mbmi);
+    update_cdf(fc->intrabc_cdf, is_intrabc, 2);
 #if CONFIG_ENTROPY_STATS
     ++td->counts->intrabc[is_intrabc_block(mbmi)];
 #endif  // CONFIG_ENTROPY_STATS
+    if (is_intrabc) {
+      const int_mv dv_ref = x->mbmi_ext_frame->ref_mv_stack[0].this_mv;
+      av1_update_mv_stats(&mbmi->mv[0].as_mv, &dv_ref.as_mv, &fc->ndvc,
+                          MV_SUBPEL_NONE);
+    }
   }
 
   if (frame_is_intra_only(cm) || mbmi->skip_mode) return;
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 389b4bf..54c1c3e 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -577,6 +577,13 @@
   }
 }
 
+void av1_fill_dv_costs(IntraBCMVCosts *dv_costs, const nmv_context *ndvc) {
+  dv_costs->dv_costs[0] = &dv_costs->dv_costs_alloc[0][MV_MAX];
+  dv_costs->dv_costs[1] = &dv_costs->dv_costs_alloc[1][MV_MAX];
+  av1_build_nmv_cost_table(dv_costs->joint_mv, dv_costs->dv_costs, ndvc,
+                           MV_SUBPEL_NONE);
+}
+
 void av1_initialize_rd_consts(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   MACROBLOCK *const x = &cpi->td.mb;
@@ -613,11 +620,7 @@
   if (!use_nonrd_pick_mode && frame_is_intra_only(cm) &&
       cm->features.allow_screen_content_tools &&
       !is_stat_generation_stage(cpi)) {
-    IntraBCMVCosts *const dv_costs = &cpi->dv_costs;
-    int *dvcost[2] = { &dv_costs->mv_component[0][MV_MAX],
-                       &dv_costs->mv_component[1][MV_MAX] };
-    av1_build_nmv_cost_table(dv_costs->joint_mv, dvcost, &cm->fc->ndvc,
-                             MV_SUBPEL_NONE);
+    av1_fill_dv_costs(x->dv_costs, &cm->fc->ndvc);
   }
 }
 
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index e37c86b..0231c2b 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -81,20 +81,6 @@
   double r0;
 } RD_OPT;
 
-typedef struct {
-  // Cost of transmitting the actual motion vector.
-  // mv_component[0][i] is the cost of motion vector with horizontal component
-  // (mv_row) equal to i - MV_MAX.
-  // mv_component[1][i] is the cost of motion vector with vertical component
-  // (mv_col) equal to i - MV_MAX.
-  int mv_component[2][MV_VALS];
-
-  // joint_mv[i] is the cost of transmitting joint mv(MV_JOINT_TYPE) of
-  // type i.
-  // TODO(huisu@google.com): we can update dv_joint_cost per SB.
-  int joint_mv[MV_JOINTS];
-} IntraBCMVCosts;
-
 static INLINE void av1_init_rd_stats(RD_STATS *rd_stats) {
 #if CONFIG_RD_DEBUG
   int plane;
@@ -375,6 +361,8 @@
 void av1_fill_mv_costs(const nmv_context *nmvc, int integer_mv, int usehp,
                        MvCosts *mv_costs);
 
+void av1_fill_dv_costs(IntraBCMVCosts *dv_costs, const nmv_context *ndvc);
+
 int av1_get_adaptive_rdmult(const struct AV1_COMP *cpi, double beta);
 
 int av1_get_deltaq_offset(const struct AV1_COMP *cpi, int qindex, double beta);
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index d41f3d0..8c0fb36 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2932,7 +2932,7 @@
   const int sb_col = mi_col >> cm->seq_params.mib_size_log2;
 
   MB_MODE_INFO_EXT *const mbmi_ext = &x->mbmi_ext;
-  MV_REFERENCE_FRAME ref_frame = INTRA_FRAME;
+  const MV_REFERENCE_FRAME ref_frame = INTRA_FRAME;
   av1_find_mv_refs(cm, xd, mbmi, ref_frame, mbmi_ext->ref_mv_count,
                    xd->ref_mv_stack, xd->weight, NULL, mbmi_ext->global_mvs,
                    mbmi_ext->mode_context);
@@ -2983,7 +2983,7 @@
   av1_make_default_fullpel_ms_params(&fullms_params, cpi, x, bsize,
                                      &dv_ref.as_mv, lookahead_search_sites,
                                      /*fine_search_interval=*/0);
-  const IntraBCMVCosts *const dv_costs = &cpi->dv_costs;
+  const IntraBCMVCosts *const dv_costs = x->dv_costs;
   av1_set_ms_to_intra_mode(&fullms_params, dv_costs);
 
   for (enum IntrabcMotionDirection dir = IBC_MOTION_ABOVE;
@@ -3065,12 +3065,10 @@
     av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, NULL, bsize, 0,
                                   av1_num_planes(cm) - 1);
 
-    int *dvcost[2] = { (int *)&dv_costs->mv_component[0][MV_MAX],
-                       (int *)&dv_costs->mv_component[1][MV_MAX] };
     // TODO(aconverse@google.com): The full motion field defining discount
     // in MV_COST_WEIGHT is too large. Explore other values.
     const int rate_mv = av1_mv_bit_cost(&dv, &dv_ref.as_mv, dv_costs->joint_mv,
-                                        dvcost, MV_COST_WEIGHT_SUB);
+                                        dv_costs->dv_costs, MV_COST_WEIGHT_SUB);
     const int rate_mode = x->mode_costs.intrabc_cost[1];
     RD_STATS rd_stats_yuv, rd_stats_y, rd_stats_uv;
     if (!av1_txfm_search(cpi, x, bsize, &rd_stats_yuv, &rd_stats_y,
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 2244aaa..5587c4f 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -291,6 +291,7 @@
   sf->part_sf.ml_predict_breakout_level = use_hbd ? 1 : 3;
 
   sf->intra_sf.intra_pruning_with_hog = 1;
+  sf->intra_sf.dv_cost_upd_level = 3;
 
   sf->tx_sf.adaptive_txb_search_level = 1;
   sf->tx_sf.intra_tx_size_search_init_depth_sqr = 1;
@@ -1103,6 +1104,7 @@
 
   sf->interp_sf.use_fast_interpolation_filter_search = 1;
 
+  sf->intra_sf.dv_cost_upd_level = 3;
   sf->intra_sf.intra_pruning_with_hog = 1;
 
   sf->mv_sf.full_pixel_search_level = 1;
@@ -1529,6 +1531,8 @@
 }
 
 static AOM_INLINE void init_intra_sf(INTRA_MODE_SPEED_FEATURES *intra_sf) {
+  intra_sf->chroma_intra_pruning_with_hog = 0;
+  intra_sf->dv_cost_upd_level = 0;
   intra_sf->skip_intra_in_interframe = 1;
   intra_sf->intra_pruning_with_hog = 0;
   intra_sf->chroma_intra_pruning_with_hog = 0;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index 90765fe..0da1377 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -727,6 +727,7 @@
   // 0: update happens at each sb level.
   // 1: update happens once for each sb row.
   // 2: update happens once for a set of rows.
+  // 3: skips updates
   int mv_cost_upd_level;
   // Prune inter modes based on tpl stats
   // 0 : no pruning
@@ -825,6 +826,14 @@
   // 1: Prune chroma intra modes other than UV_DC_PRED, UV_SMOOTH_PRED,
   // UV_CFL_PRED and the mode that corresponds to luma intra mode winner.
   int prune_chroma_modes_using_luma_winner;
+
+  // To skip cost update for mv.
+  // dv_cost_upd_level indicates the aggressiveness of skipping.
+  // 0: update happens at each sb level.
+  // 1: update happens once for each sb row.
+  // 2: update happens once for a set of rows.
+  // 3: skips updates
+  int dv_cost_upd_level;
 } INTRA_MODE_SPEED_FEATURES;
 
 typedef struct TX_SPEED_FEATURES {