Fix build issues when some experiments are disabled

Fixes for CONFIG_EXTENDED_WARP_PREDICTION=0:

* Move some things which were accidentally inside a
  "#if CONFIG_EXTENDED_WARP_PREDICTION" block when they
  weren't meant to be

* Conversely, guard a few lines which were accidentally left unguarded

* Restore "is this block interintra?" logic to what it was in AV1
  when EXTENDED_WARP_PREDICTION is disabled

* Properly disable all experiments which build on top of
  EXTENDED_WARP_PREDICTION when this tool is disabled

Fixes for CONFIG_INTERINTRA_IMPROVEMENT=0:
    
* Remove assertion in is_interintra_pred when INTERINTRA_IMPROVEMENT
  is disabled. This is necessary because, without this experiment,
  mbmi->ref_frame[1] is not necessarily set properly for interintra
  mode during motion mode search.

Fixes https://gitlab.com/AOMediaCodec/avm/-/issues/265
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 9be0c17..d29ec04 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -3553,7 +3553,12 @@
 #define MAX_INTERINTRA_SB_SQUARE 32 * 32
 #endif  // CONFIG_INTERINTRA_IMPROVEMENT
 static INLINE int is_interintra_mode(const MB_MODE_INFO *mbmi) {
+#if CONFIG_EXTENDED_WARP_PREDICTION
   return mbmi->motion_mode == INTERINTRA;
+#else
+  return (mbmi->ref_frame[0] > INTRA_FRAME &&
+          mbmi->ref_frame[1] == INTRA_FRAME);
+#endif  // CONFIG_EXTENDED_WARP_PREDICTION
 }
 
 #if CONFIG_EXT_RECUR_PARTITIONS
@@ -3623,13 +3628,9 @@
 
 static INLINE int is_interintra_pred(const MB_MODE_INFO *mbmi) {
 #if CONFIG_INTERINTRA_IMPROVEMENT
-  assert(IMPLIES(mbmi->motion_mode == INTERINTRA,
-                 mbmi->ref_frame[1] == NONE_FRAME));
-#else
-  assert(IMPLIES(mbmi->motion_mode == INTERINTRA,
-                 mbmi->ref_frame[1] == INTRA_FRAME));
+  assert(IMPLIES(is_interintra_mode(mbmi), mbmi->ref_frame[1] == NONE_FRAME));
 #endif  // CONFIG_INTERINTRA_IMPROVEMENT
-  return (mbmi->motion_mode == INTERINTRA);
+  return is_interintra_mode(mbmi);
 }
 
 static INLINE int get_vartx_max_txsize(const MACROBLOCKD *xd, BLOCK_SIZE bsize,
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 7174ebd..bbe4367 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -3271,7 +3271,6 @@
     };
 #endif  // CONFIG_D149_CTX_MODELING_OPT
 
-#if CONFIG_EXTENDED_WARP_PREDICTION
 #if CONFIG_D149_CTX_MODELING_OPT
 static const aom_cdf_prob default_warped_causal_warpmv_cdf[CDF_SIZE(2)] = {
   AOM_CDF2(16384),
@@ -3296,35 +3295,6 @@
 #endif  // CONFIG_FLEX_PARTITION
     };
 #endif  // CONFIG_D149_CTX_MODELING_OPT
-#endif  // CONFIG_EXTENDED_WARP_PREDICTION
-
-#if CONFIG_REFINEMV
-#if CONFIG_ENTROPY_PARA
-static const aom_cdf_prob
-    default_refinemv_flag_cdf[NUM_REFINEMV_CTX][CDF_SIZE(2)] = {
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 1 }, { AOM_CDF2(16384), 1 },
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
-      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
-    };
-#else
-static const aom_cdf_prob default_refinemv_flag_cdf[NUM_REFINEMV_CTX][CDF_SIZE(
-    REFINEMV_NUM_MODES)] = {
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
-  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
-};
-#endif  // CONFIG_ENTROPY_PARA
-#endif  // CONFIG_REFINEMV
 
 #if CONFIG_D149_CTX_MODELING_OPT
 static const aom_cdf_prob default_warp_delta_cdf[CDF_SIZE(2)] = {
@@ -3351,7 +3321,6 @@
     };
 #endif  // CONFIG_D149_CTX_MODELING_OPT
 
-#if CONFIG_EXTENDED_WARP_PREDICTION
 #if CONFIG_ENTROPY_PARA
 static const aom_cdf_prob default_warp_ref_idx0_cdf[WARP_REF_CONTEXTS]
                                                    [CDF_SIZE(2)] = {
@@ -3398,7 +3367,6 @@
 #endif  // CONFIG_FLEX_PARTITION
     };
 #endif  // CONFIG_D149_CTX_MODELING_OPT
-#endif  // CONFIG_EXTENDED_WARP_PREDICTION
 
 #if CONFIG_ENTROPY_PARA
 static const aom_cdf_prob
@@ -3531,6 +3499,34 @@
 #endif  // CONFIG_D149_CTX_MODELING_OPT
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
 
+#if CONFIG_REFINEMV
+#if CONFIG_ENTROPY_PARA
+static const aom_cdf_prob
+    default_refinemv_flag_cdf[NUM_REFINEMV_CTX][CDF_SIZE(2)] = {
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 1 }, { AOM_CDF2(16384), 1 },
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
+      { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 }, { AOM_CDF2(16384), 0 },
+    };
+#else
+static const aom_cdf_prob default_refinemv_flag_cdf[NUM_REFINEMV_CTX][CDF_SIZE(
+    REFINEMV_NUM_MODES)] = {
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) },
+  { AOM_CDF2(16384) }, { AOM_CDF2(16384) }, { AOM_CDF2(16384) }
+};
+#endif  // CONFIG_ENTROPY_PARA
+#endif  // CONFIG_REFINEMV
+
 #if CONFIG_BAWP
 #if CONFIG_ENTROPY_PARA
 static const aom_cdf_prob default_bawp_cdf[CDF_SIZE(2)] = { AOM_CDF2(23664),
diff --git a/av1/common/mv.h b/av1/common/mv.h
index 9789719..77c65af 100644
--- a/av1/common/mv.h
+++ b/av1/common/mv.h
@@ -558,11 +558,11 @@
   // candidate, and so does not allow WARP_EXTEND
   int row_offset;
   int col_offset;
+#endif  // CONFIG_EXTENDED_WARP_PREDICTION
 #if CONFIG_CWP
   // Record the cwp index of the neighboring blocks
   int8_t cwp_idx;
 #endif  // CONFIG_CWP
-#endif  // CONFIG_EXTENDED_WARP_PREDICTION
 } CANDIDATE_MV;
 
 #if CONFIG_EXTENDED_WARP_PREDICTION
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 5de798c..aee7938 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -3264,7 +3264,9 @@
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
       );
     }
+#if CONFIG_EXTENDED_WARP_PREDICTION
     if (derive_wrl) assert(rf[0] == ref_frame);
+#endif  // CONFIG_EXTENDED_WARP_PREDICTION
 #else
     setup_ref_mv_list(cm, xd, ref_frame, &ref_mv_count[ref_frame],
                       ref_mv_stack[ref_frame], ref_mv_weight[ref_frame], NULL,
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index aa8ded1..3683609 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1295,7 +1295,7 @@
     );
 
     assert(IMPLIES(!is_interintra_allowed(xd->mi[0]),
-                   xd->mi[0]->motion_mode != INTERINTRA));
+                   !is_interintra_mode(xd->mi[0])));
 
     if (is_interintra_pred(xd->mi[0])) {
       BUFFER_SET ctx = { { xd->plane[0].dst.buf, xd->plane[1].dst.buf,
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index e2d49c2..17be33d 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -678,7 +678,9 @@
   if (last_motion_mode_allowed == SIMPLE_TRANSLATION) return SIMPLE_TRANSLATION;
 
   if (last_motion_mode_allowed == OBMC_CAUSAL) {
+#if !CONFIG_D149_CTX_MODELING_OPT
     const int bsize = mbmi->sb_type[PLANE_TYPE_Y];
+#endif  // !CONFIG_D149_CTX_MODELING_OPT
     motion_mode = aom_read_symbol(r,
 #if CONFIG_D149_CTX_MODELING_OPT
                                   xd->tile_ctx->obmc_cdf,
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 12c3274..f152805 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -753,7 +753,9 @@
   switch (last_motion_mode_allowed) {
     case SIMPLE_TRANSLATION: break;
     case OBMC_CAUSAL:
+#if !CONFIG_D149_CTX_MODELING_OPT
       const int bsize = mbmi->sb_type[PLANE_TYPE_Y];
+#endif  // !CONFIG_D149_CTX_MODELING_OPT
       aom_write_symbol(w, mbmi->motion_mode == OBMC_CAUSAL,
 #if CONFIG_D149_CTX_MODELING_OPT
                        xd->tile_ctx->obmc_cdf,
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index c1f0003..fa64902 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -1125,11 +1125,6 @@
   int warped_causal_warpmv_cost[BLOCK_SIZES_ALL][2];
 #endif  // CONFIG_D149_CTX_MODELING_OPT
 
-#if CONFIG_REFINEMV
-  //! refinemv_flag_cost
-  int refinemv_flag_cost[NUM_REFINEMV_CTX][REFINEMV_NUM_MODES];
-#endif  // CONFIG_REFINEMV
-
   //! warp_delta_param_cost
   int warp_delta_param_cost[2][WARP_DELTA_NUM_SYMBOLS];
   //! warp_ref_idx_cost
@@ -1146,6 +1141,10 @@
   //! motion_mode_cost
   int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES];
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
+#if CONFIG_REFINEMV
+  //! refinemv_flag_cost
+  int refinemv_flag_cost[NUM_REFINEMV_CTX][REFINEMV_NUM_MODES];
+#endif  // CONFIG_REFINEMV
 #if CONFIG_BAWP
   //! bawp flag cost
 #if CONFIG_BAWP_CHROMA
diff --git a/av1/encoder/compound_type.c b/av1/encoder/compound_type.c
index b8cd513..fefd3d4 100644
--- a/av1/encoder/compound_type.c
+++ b/av1/encoder/compound_type.c
@@ -510,10 +510,12 @@
   int64_t dist, skip_sse_sb;
   const int bw = block_size_wide[bsize];
   mbmi->interintra_mode = interintra_mode;
-  assert(mbmi->motion_mode == INTERINTRA);
+#if CONFIG_EXTENDED_WARP_PREDICTION
+  assert(is_interintra_mode(mbmi));
 #if CONFIG_INTERINTRA_IMPROVEMENT
   assert(mbmi->ref_frame[1] == NONE_FRAME);
 #endif  // CONFIG_INTERINTRA_IMPROVEMENT
+#endif  // CONFIG_EXTENDED_WARP_PREDICTION
 
   int rmode = interintra_mode_cost[interintra_mode];
 #if CONFIG_EXT_RECUR_PARTITIONS
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 66ea9aa..a40a9d0 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -394,7 +394,12 @@
 
   // Optical flow MV search is allowed for NEWMV and WARPMV only, since it
   // shows little improvements in compound modes.
-  if (mbmi->mode == WARPMV || mbmi->mode == NEWMV) return 3;
+  if (mbmi->mode == NEWMV
+#if CONFIG_EXTENDED_WARP_PREDICTION
+      || mbmi->mode == WARPMV
+#endif  // CONFIG_EXTENDED_WARP_PREDICTION
+  )
+    return 3;
 
   return 0;
 }
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index d6cdbbb..d0932f2 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -351,7 +351,12 @@
 // search. The purpose for upscaling the MVD is to increase the search range and
 // obtain a new search point not covered by the traditional local search.
 static INLINE int get_opfl_mv_upshift_bits(const MB_MODE_INFO *mbmi) {
-  if (mbmi->mode == NEWMV || mbmi->mode == WARPMV) return 3;
+  if (mbmi->mode == NEWMV
+#if CONFIG_EXTENDED_WARP_PREDICTION
+      || mbmi->mode == WARPMV
+#endif  // CONFIG_EXTENDED_WARP_PREDICTION
+  )
+    return 3;
   return 0;
 }
 
diff --git a/av1/encoder/motion_search_facade.c b/av1/encoder/motion_search_facade.c
index 5ece214..536c1ee 100644
--- a/av1/encoder/motion_search_facade.c
+++ b/av1/encoder/motion_search_facade.c
@@ -1165,8 +1165,10 @@
   const YV12_BUFFER_CONFIG *const scaled_ref_frame =
       av1_get_scaled_ref_frame(cpi, ref);
 
+#if CONFIG_EXTENDED_WARP_PREDICTION
   // Check that this is either an interinter or an interintra block
   assert(has_second_ref(mbmi) || (ref_idx == 0 && is_interintra_mode(mbmi)));
+#endif  // CONFIG_EXTENDED_WARP_PREDICTION
 
   // Store the first prediction buffer.
   struct buf_2d orig_yv12;
diff --git a/build/cmake/aom_experiment_deps.cmake b/build/cmake/aom_experiment_deps.cmake
index 65980c8..38763c8 100644
--- a/build/cmake/aom_experiment_deps.cmake
+++ b/build/cmake/aom_experiment_deps.cmake
@@ -61,6 +61,18 @@
     change_config_and_warn(CONFIG_EXPLICIT_BAWP 0 !CONFIG_BAWP)
   endif()
 
+  # Tools which depend on CONFIG_EXTENDED_WARP_PREDICTION
+  if(NOT CONFIG_EXTENDED_WARP_PREDICTION)
+    change_config_and_warn(CONFIG_EXT_WARP_FILTER 0
+                           !CONFIG_EXTENDED_WARP_PREDICTION)
+    change_config_and_warn(CONFIG_INTERINTRA_IMPROVEMENT 0
+                           !CONFIG_EXTENDED_WARP_PREDICTION)
+    change_config_and_warn(CONFIG_COMPOUND_WARP_CAUSAL 0
+                           !CONFIG_EXTENDED_WARP_PREDICTION)
+    change_config_and_warn(CONFIG_AFFINE_REFINEMENT 0
+                           !CONFIG_EXTENDED_WARP_PREDICTION)
+  endif()
+
   # CONFIG_EXT_WARP_FILTER depends on CONFIG_EXTENDED_WARP_PREDICTION
   if(NOT CONFIG_EXTENDED_WARP_PREDICTION AND CONFIG_EXT_WARP_FILTER)
     change_config_and_warn(CONFIG_EXT_WARP_FILTER 0