rtc: Populate features->switchable_motion_mode appropriately

In this CL, features->switchable_motion_mode is populated
based on allowed motion modes. When OBMC and warp tools are
disabled, features->switchable_motion_mode is set to false.
Thus, the computations related to signaling motion mode are
avoided.

For rtc,
               Instruction Count        BD-Rate Loss(%)
cpu Resolution   Reduction(%)    avg.psnr   ovr.psnr    ssim
 7         rtc      0.251         0.0073     0.0061   -0.0386
 7    rtc_derf      0.323         0.0341     0.0289    0.0290
 7  rtc_screen      0.146        -0.0253    -0.0208    0.0603
 8         rtc      0.310        -0.0733    -0.0693   -0.0154
 8    rtc_derf      0.418         0.1480     0.1469    0.1906
 8  rtc_screen      0.028        -0.7676    -0.1882   -0.3181
 9         rtc      0.287         0.0795     0.0564    0.0400
 9    rtc_derf      0.339         0.0226     0.0127    0.0457
 9  rtc_screen      0.311        -0.1215     0.0792    0.1363
10         rtc      0.263        -0.0532    -0.1052   -0.1043
10    rtc_derf      0.271        -0.1469    -0.1696   -0.2264
10  rtc_screen      0.148        -0.2022    -0.3691   -0.2984

STATS_CHANGED

Change-Id: I303650ed8a0273f71e2890e10f61769106d47618
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index e2381cd..548709a 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1982,9 +1982,10 @@
   FeatureFlags *const features = &cm->features;
   const int num_planes = av1_num_planes(cm);
   RD_COUNTS *const rdc = &cpi->td.rd_counts;
+  const AV1EncoderConfig *const oxcf = &cpi->oxcf;
   // Indicates whether or not to use a default reduced set for ext-tx
   // rather than the potential full set of 16 transforms
-  features->reduced_tx_set_used = cpi->oxcf.txfm_cfg.reduced_tx_type_set;
+  features->reduced_tx_set_used = oxcf->txfm_cfg.reduced_tx_type_set;
 
   // Make sure segment_id is no larger than last_active_segid.
   if (cm->seg.enabled && cm->seg.update_map) {
@@ -2026,7 +2027,8 @@
     features->interp_filter = SWITCHABLE;
     if (cm->tiles.large_scale) features->interp_filter = EIGHTTAP_REGULAR;
 
-    features->switchable_motion_mode = 1;
+    features->switchable_motion_mode = is_switchable_motion_mode_allowed(
+        features->allow_warped_motion, oxcf->motion_mode_cfg.enable_obmc);
 
     rdc->compound_ref_used_flag = 0;
     rdc->skip_mode_used_flag = 0;
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index ea862ed..51c1d4b 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -696,6 +696,7 @@
   RefreshFrameInfo *const refresh_frame = &cpi->refresh_frame;
   const FrameDimensionCfg *const frm_dim_cfg = &cpi->oxcf.frm_dim_cfg;
   const RateControlCfg *const rc_cfg = &oxcf->rc_cfg;
+  FeatureFlags *const features = &cm->features;
 
   // in case of LAP, lag in frames is set according to number of lap buffers
   // calculated at init time. This stores and restores LAP's lag in frames to
@@ -750,12 +751,12 @@
   refresh_frame->golden_frame = false;
   refresh_frame->bwd_ref_frame = false;
 
-  cm->features.refresh_frame_context =
+  features->refresh_frame_context =
       (oxcf->tool_cfg.frame_parallel_decoding_mode)
           ? REFRESH_FRAME_CONTEXT_DISABLED
           : REFRESH_FRAME_CONTEXT_BACKWARD;
   if (oxcf->tile_cfg.enable_large_scale_tile)
-    cm->features.refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
+    features->refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
 
   if (x->palette_buffer == NULL) {
     CHECK_MEM_ERROR(cm, x->palette_buffer,
@@ -803,9 +804,10 @@
   rc->worst_quality = rc_cfg->worst_allowed_q;
   rc->best_quality = rc_cfg->best_allowed_q;
 
-  cm->features.interp_filter =
+  features->interp_filter =
       oxcf->tile_cfg.enable_large_scale_tile ? EIGHTTAP_REGULAR : SWITCHABLE;
-  cm->features.switchable_motion_mode = 1;
+  features->switchable_motion_mode = is_switchable_motion_mode_allowed(
+      features->allow_warped_motion, oxcf->motion_mode_cfg.enable_obmc);
 
   if (frm_dim_cfg->render_width > 0 && frm_dim_cfg->render_height > 0) {
     cm->render_width = frm_dim_cfg->render_width;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 19e4a9c..2ec7770 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -4090,6 +4090,12 @@
           tx_sf->inter_tx_size_search_init_depth_sqr >= 1);
 }
 
+// Enable switchable motion mode only if warp and OBMC tools are allowed
+static INLINE bool is_switchable_motion_mode_allowed(bool allow_warped_motion,
+                                                     bool enable_obmc) {
+  return (allow_warped_motion || enable_obmc);
+}
+
 #if CONFIG_AV1_TEMPORAL_DENOISING
 static INLINE int denoise_svc(const struct AV1_COMP *const cpi) {
   return (!cpi->ppi->use_svc ||
diff --git a/av1/encoder/encoder_utils.h b/av1/encoder/encoder_utils.h
index 6fb22bd..427cd83 100644
--- a/av1/encoder/encoder_utils.h
+++ b/av1/encoder/encoder_utils.h
@@ -974,6 +974,7 @@
 static AOM_INLINE void set_size_independent_vars(AV1_COMP *cpi) {
   int i;
   AV1_COMMON *const cm = &cpi->common;
+  FeatureFlags *const features = &cm->features;
   for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) {
     cm->global_motion[i] = default_warp_params;
   }
@@ -981,8 +982,9 @@
 
   av1_set_speed_features_framesize_independent(cpi, cpi->speed);
   av1_set_rd_speed_thresholds(cpi);
-  cm->features.interp_filter = SWITCHABLE;
-  cm->features.switchable_motion_mode = 1;
+  features->interp_filter = SWITCHABLE;
+  features->switchable_motion_mode = is_switchable_motion_mode_allowed(
+      features->allow_warped_motion, cpi->oxcf.motion_mode_cfg.enable_obmc);
 }
 
 static AOM_INLINE void release_scaled_references(AV1_COMP *cpi) {
diff --git a/av1/encoder/nonrd_opt.h b/av1/encoder/nonrd_opt.h
index 9fcb724..8a25061 100644
--- a/av1/encoder/nonrd_opt.h
+++ b/av1/encoder/nonrd_opt.h
@@ -101,7 +101,9 @@
                   bsize);
     }
   }
-  av1_count_overlappable_neighbors(cm, xd);
+  if (cm->features.switchable_motion_mode) {
+    av1_count_overlappable_neighbors(cm, xd);
+  }
   mbmi->num_proj_ref = 1;
 }