Hide SVC features in CONFIG_SVC_ENCODER flag

The code is CONFIG_SVC_ENCODER is to be subsequently removed.

Change-Id: I4cdc2aec88abb44ff246d8482a3993e34b2d2452
diff --git a/aom/aomcx.h b/aom/aomcx.h
index f44ceed..396463f 100644
--- a/aom/aomcx.h
+++ b/aom/aomcx.h
@@ -1201,8 +1201,9 @@
    */
   AV1E_SET_MIN_CR = 144,
 
-  /* NOTE: enums 145-149 unused */
+/* NOTE: enums 145-149 unused */
 
+#if CONFIG_SVC_ENCODER
   /*!\brief Codec control function to set the layer id, aom_svc_layer_id_t*
    * parameter
    */
@@ -1218,6 +1219,7 @@
    * aom_svc_ref_frame_config_t* parameter
    */
   AV1E_SET_SVC_REF_FRAME_CONFIG = 152,
+#endif  // CONFIG_SVC_ENCODER
 
   /*!\brief Codec control function to set the path to the VMAF model used when
    * tuning the encoder for VMAF, const char* parameter
@@ -1389,6 +1391,7 @@
   AOM_TUNE_VMAF_NEG_MAX_GAIN = 7,
 } aom_tune_metric;
 
+#if CONFIG_SVC_ENCODER
 #define AOM_MAX_LAYERS 32   /**< Max number of layers */
 #define AOM_MAX_SS_LAYERS 4 /**< Max number of spatial layers */
 #define AOM_MAX_TS_LAYERS 8 /**< Max number of temporal layers */
@@ -1422,6 +1425,7 @@
   int ref_idx[7];
   int refresh[8]; /**< Refresh flag for each of the 8 slots. */
 } aom_svc_ref_frame_config_t;
+#endif  // CONFIG_SVC_ENCODER
 
 /*!\cond */
 /*!\brief Encoder control function parameter type
@@ -1809,6 +1813,7 @@
 AOM_CTRL_USE_TYPE(AV1E_SET_MIN_CR, unsigned int)
 #define AOM_CTRL_AV1E_SET_MIN_CR
 
+#if CONFIG_SVC_ENCODER
 AOM_CTRL_USE_TYPE(AV1E_SET_SVC_LAYER_ID, aom_svc_layer_id_t *)
 #define AOME_CTRL_AV1E_SET_SVC_LAYER_ID
 
@@ -1817,6 +1822,7 @@
 
 AOM_CTRL_USE_TYPE(AV1E_SET_SVC_REF_FRAME_CONFIG, aom_svc_ref_frame_config_t *)
 #define AOME_CTRL_AV1E_SET_SVC_REF_FRAME_CONFIG
+#endif  // CONFIG_SVC_ENCODER
 
 AOM_CTRL_USE_TYPE(AV1E_ENABLE_SB_MULTIPASS_UNIT_TEST, unsigned int)
 #define AOM_CTRL_AV1E_ENABLE_SB_MULTIPASS_UNIT_TEST
diff --git a/av1/av1.cmake b/av1/av1.cmake
index 89a662b..87ea535 100644
--- a/av1/av1.cmake
+++ b/av1/av1.cmake
@@ -241,8 +241,6 @@
   "${AOM_ROOT}/av1/encoder/subgop.h"
   "${AOM_ROOT}/av1/encoder/superres_scale.c"
   "${AOM_ROOT}/av1/encoder/superres_scale.h"
-  "${AOM_ROOT}/av1/encoder/svc_layercontext.c"
-  "${AOM_ROOT}/av1/encoder/svc_layercontext.h"
   "${AOM_ROOT}/av1/encoder/temporal_filter.c"
   "${AOM_ROOT}/av1/encoder/temporal_filter.h"
   "${AOM_ROOT}/av1/encoder/tokenize.c"
@@ -266,6 +264,12 @@
   "${AOM_ROOT}/av1/encoder/dwt.c"
   "${AOM_ROOT}/av1/encoder/dwt.h")
 
+if(CONFIG_SVC_ENCODER)
+  list(APPEND AOM_AV1_ENCODER_SOURCES
+       "${AOM_ROOT}/av1/encoder/svc_layercontext.c"
+       "${AOM_ROOT}/av1/encoder/svc_layercontext.h")
+endif()
+
 if(CONFIG_TUNE_VMAF)
   list(APPEND AOM_AV1_ENCODER_SOURCES "${AOM_ROOT}/av1/encoder/tune_vmaf.c"
        "${AOM_ROOT}/av1/encoder/tune_vmaf.h")
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 7ac3772..cbdc147 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -2578,14 +2578,20 @@
 
 static aom_codec_frame_flags_t get_frame_pkt_flags(const AV1_COMP *cpi,
                                                    unsigned int lib_flags) {
+#if CONFIG_SVC_ENCODER
   const SVC *const svc = &cpi->svc;
+#endif  // CONFIG_SVC_ENCODER
   aom_codec_frame_flags_t flags = lib_flags << 16;
 
+#if CONFIG_SVC_ENCODER
   if (lib_flags & FRAMEFLAGS_KEY ||
       (cpi->use_svc &&
        svc->layer_context[svc->spatial_layer_id * svc->number_temporal_layers +
                           svc->temporal_layer_id]
            .is_key_frame))
+#else
+  if (lib_flags & FRAMEFLAGS_KEY)
+#endif  // CONFIG_SVC_ENCODER
     flags |= AOM_FRAME_IS_KEY;
   if (lib_flags & FRAMEFLAGS_INTRAONLY) flags |= AOM_FRAME_IS_INTRAONLY;
   if (lib_flags & FRAMEFLAGS_SWITCH) flags |= AOM_FRAME_IS_SWITCH;
@@ -3205,6 +3211,7 @@
   return AOM_CODEC_OK;
 }
 
+#if CONFIG_SVC_ENCODER
 static aom_codec_err_t ctrl_set_layer_id(aom_codec_alg_priv_t *ctx,
                                          va_list args) {
   aom_svc_layer_id_t *const data = va_arg(args, aom_svc_layer_id_t *);
@@ -3268,6 +3275,7 @@
     cpi->svc.refresh[i] = data->refresh[i];
   return AOM_CODEC_OK;
 }
+#endif  // CONFIG_SVC_ENCODER
 
 static aom_codec_err_t ctrl_set_tune_content(aom_codec_alg_priv_t *ctx,
                                              va_list args) {
@@ -3917,9 +3925,11 @@
   { AV1E_SET_TARGET_SEQ_LEVEL_IDX, ctrl_set_target_seq_level_idx },
   { AV1E_SET_TIER_MASK, ctrl_set_tier_mask },
   { AV1E_SET_MIN_CR, ctrl_set_min_cr },
+#if CONFIG_SVC_ENCODER
   { AV1E_SET_SVC_LAYER_ID, ctrl_set_layer_id },
   { AV1E_SET_SVC_PARAMS, ctrl_set_svc_params },
   { AV1E_SET_SVC_REF_FRAME_CONFIG, ctrl_set_svc_ref_frame_config },
+#endif  // CONFIG_SVC_ENCODER
   { AV1E_SET_VBR_CORPUS_COMPLEXITY_LAP, ctrl_set_vbr_corpus_complexity_lap },
   { AV1E_ENABLE_SB_MULTIPASS_UNIT_TEST, ctrl_enable_sb_multipass_unit_test },
   { AV1E_ENABLE_SUBGOP_STATS, ctrl_enable_subgop_stats },
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index 4dbaf90..81a9fa4 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -377,7 +377,9 @@
   int qp_max_thresh = 118 * MAXQ >> 7;
   cr->apply_cyclic_refresh = 1;
   if (frame_is_intra_only(cm) || is_lossless_requested(&cpi->oxcf.rc_cfg) ||
+#if CONFIG_SVC_ENCODER
       cpi->svc.temporal_layer_id > 0 ||
+#endif  // CONFIG_SVC_ENCODER
       rc->avg_frame_qindex[INTER_FRAME] < qp_thresh ||
       (rc->frames_since_key > 20 &&
        rc->avg_frame_qindex[INTER_FRAME] > qp_max_thresh) ||
diff --git a/av1/encoder/av1_noise_estimate.c b/av1/encoder/av1_noise_estimate.c
index 79de012..58c3152 100644
--- a/av1/encoder/av1_noise_estimate.c
+++ b/av1/encoder/av1_noise_estimate.c
@@ -23,13 +23,15 @@
 #include "av1/encoder/encoder.h"
 
 #if CONFIG_AV1_TEMPORAL_DENOISING
+#if CONFIG_SVC_ENCODER
 // For SVC: only do noise estimation on top spatial layer.
 static INLINE int noise_est_svc(const struct AV1_COMP *const cpi) {
   return (!cpi->use_svc ||
           (cpi->use_svc &&
            cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1));
 }
-#endif
+#endif  // CONFIG_SVC_ENCODER
+#endif  // CONFIG_AV1_TEMPORAL_DENOISING
 
 void av1_noise_estimate_init(NOISE_ESTIMATE *const ne, int width, int height) {
   ne->enabled = 0;
@@ -62,7 +64,10 @@
 
 // Enable noise estimation if denoising is on.
 #if CONFIG_AV1_TEMPORAL_DENOISING
-  if (cpi->oxcf.noise_sensitivity > 0 && noise_est_svc(cpi) &&
+  if (cpi->oxcf.noise_sensitivity > 0 &&
+#if CONFIG_SVC_ENCODER
+      noise_est_svc(cpi) &&
+#endif  // CONFIG_SVC_ENCODER
       cpi->common.width >= 320 && cpi->common.height >= 180)
     return 1;
 #endif
@@ -72,7 +77,10 @@
   // Not enabled for low resolutions.
   if (cpi->oxcf.pass == 0 && cpi->oxcf.rc_cfg.mode == AOM_CBR &&
       cpi->oxcf.q_cfg.aq_mode == CYCLIC_REFRESH_AQ && cpi->oxcf.speed >= 5 &&
-      resize_pending == 0 && !cpi->use_svc &&
+      resize_pending == 0 &&
+#if CONFIG_SVC_ENCODER
+      !cpi->use_svc &&
+#endif  // CONFIG_SVC_ENCODER
       cpi->oxcf.tune_cfg.content != AOM_CONTENT_SCREEN &&
       cpi->common.width * cpi->common.height >= 640 * 360)
     return 1;
@@ -117,7 +125,9 @@
   const CommonModeInfoParams *const mi_params = &cm->mi_params;
 
   NOISE_ESTIMATE *const ne = &cpi->noise_estimate;
+#if CONFIG_SVC_ENCODER
   const int low_res = (cm->width <= 352 && cm->height <= 288);
+#endif  // CONFIG_SVC_ENCODER
   // Estimate of noise level every frame_period frames.
   int frame_period = 8;
   int thresh_consec_zeromv = 6;
@@ -125,7 +135,11 @@
   // Estimate is between current source and last source.
   YV12_BUFFER_CONFIG *last_source = cpi->last_source;
 #if CONFIG_AV1_TEMPORAL_DENOISING
-  if (cpi->oxcf.noise_sensitivity > 0 && noise_est_svc(cpi)) {
+  if (cpi->oxcf.noise_sensitivity > 0
+#if CONFIG_SVC_ENCODER
+      && noise_est_svc(cpi)
+#endif  // CONFIG_SVC_ENCODER
+  ) {
     last_source = &cpi->denoiser.last_source;
     // Tune these thresholds for different resolutions when denoising is
     // enabled.
@@ -135,14 +149,23 @@
   }
 #endif
   ne->enabled = enable_noise_estimation(cpi);
+#if CONFIG_SVC_ENCODER
   if (cpi->svc.number_spatial_layers > 1)
     frame_counter = cpi->svc.current_superframe;
+#endif  // CONFIG_SVC_ENCODER
   if (!ne->enabled || frame_counter % frame_period != 0 ||
       last_source == NULL ||
-      (cpi->svc.number_spatial_layers == 1 &&
-       (ne->last_w != cm->width || ne->last_h != cm->height))) {
+      (
+#if CONFIG_SVC_ENCODER
+          cpi->svc.number_spatial_layers == 1 &&
+#endif  // CONFIG_SVC_ENCODER
+          (ne->last_w != cm->width || ne->last_h != cm->height))) {
 #if CONFIG_AV1_TEMPORAL_DENOISING
-    if (cpi->oxcf.noise_sensitivity > 0 && noise_est_svc(cpi))
+    if (cpi->oxcf.noise_sensitivity > 0
+#if CONFIG_SVC_ENCODER
+        && noise_est_svc(cpi)
+#endif  // CONFIG_SVC_ENCODER
+    )
       copy_frame(&cpi->denoiser.last_source, cpi->source);
 #endif
     if (last_source != NULL) {
@@ -150,6 +173,7 @@
       ne->last_h = cm->height;
     }
     return;
+#if CONFIG_SVC_ENCODER
   } else if (frame_counter > 60 && cpi->svc.num_encoded_top_layer > 1 &&
              cpi->rc.frames_since_key > cpi->svc.number_spatial_layers &&
              cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1 &&
@@ -166,6 +190,7 @@
     }
 #endif
     return;
+#endif  // CONFIG_SVC_ENCODER
   } else {
     unsigned int bin_size = 100;
     unsigned int hist[MAX_VAR_HIST_BINS] = { 0 };
@@ -293,13 +318,21 @@
       ne->count = 0;
       ne->level = av1_noise_estimate_extract_level(ne);
 #if CONFIG_AV1_TEMPORAL_DENOISING
-      if (cpi->oxcf.noise_sensitivity > 0 && noise_est_svc(cpi))
+      if (cpi->oxcf.noise_sensitivity > 0
+#if CONFIG_SVC_ENCODER
+          && noise_est_svc(cpi)
+#endif  // CONFIG_SVC_ENCODER
+      )
         av1_denoiser_set_noise_level(cpi, ne->level);
 #endif
     }
   }
 #if CONFIG_AV1_TEMPORAL_DENOISING
-  if (cpi->oxcf.noise_sensitivity > 0 && noise_est_svc(cpi))
+  if (cpi->oxcf.noise_sensitivity > 0
+#if CONFIG_SVC_ENCODER
+      && noise_est_svc(cpi)
+#endif  // CONFIG_SVC_ENCODER
+  )
     copy_frame(&cpi->denoiser.last_source, cpi->source);
 #endif
 }
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index 74f496d..10597af 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -148,13 +148,16 @@
 }
 
 static INLINE int is_frame_droppable(
+#if CONFIG_SVC_ENCODER
     const SVC *const svc,
+#endif  // CONFIG_SVC_ENCODER
     const ExtRefreshFrameFlagsInfo *const ext_refresh_frame_flags) {
   // Droppable frame is only used by external refresh flags. VoD setting won't
   // trigger its use case.
-  if (svc->external_ref_frame_config)
-    return svc->non_reference_frame;
-  else if (ext_refresh_frame_flags->update_pending)
+#if CONFIG_SVC_ENCODER
+  if (svc->external_ref_frame_config) return svc->non_reference_frame;
+#endif  // CONFIG_SVC_ENCODER
+  if (ext_refresh_frame_flags->update_pending)
     return !(ext_refresh_frame_flags->alt_ref_frame ||
              ext_refresh_frame_flags->alt2_ref_frame ||
              ext_refresh_frame_flags->bwd_ref_frame ||
@@ -169,8 +172,11 @@
   // is a work-around to handle the condition when a frame is drop.
   // We should fix the cpi->common.show_frame flag
   // instead of checking the other condition to update the counter properly.
-  if (cpi->common.show_frame ||
-      is_frame_droppable(&cpi->svc, &cpi->ext_flags.refresh_frame)) {
+  if (cpi->common.show_frame || is_frame_droppable(
+#if CONFIG_SVC_ENCODER
+                                    &cpi->svc,
+#endif  // CONFIG_SVC_ENCODER
+                                    &cpi->ext_flags.refresh_frame)) {
     // Decrement count down till next gf
     if (cpi->rc.frames_till_gf_update_due > 0)
       cpi->rc.frames_till_gf_update_due--;
@@ -275,7 +281,9 @@
   // frame bit allocation.
   if (cm->tiles.large_scale) return (LAST_FRAME - LAST_FRAME);
 
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc) return av1_svc_primary_ref_frame(cpi);
+#endif  // CONFIG_SVC_ENCODER
 
   // Find the most recent reference frame with the same reference type as the
   // current frame
@@ -435,11 +443,13 @@
   // Clear down mmx registers
   aom_clear_system_state();
 
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc && cpi->svc.spatial_layer_id > 0) {
     cpi->framerate = cpi->svc.base_framerate;
     av1_rc_update_framerate(cpi, cpi->common.width, cpi->common.height);
     return;
   }
+#endif  // CONFIG_SVC_ENCODER
 
   if (ts_start == time_stamps->first_ever) {
     this_duration = ts_end - ts_start;
@@ -786,7 +796,9 @@
   const ExtRefreshFrameFlagsInfo *const ext_refresh_frame_flags =
       &cpi->ext_flags.refresh_frame;
 
+#if CONFIG_SVC_ENCODER
   const SVC *const svc = &cpi->svc;
+#endif  // CONFIG_SVC_ENCODER
   // Switch frames and shown key-frames overwrite all reference slots
   if ((frame_params->frame_type == KEY_FRAME && !cpi->no_show_fwd_kf) ||
       frame_params->frame_type == S_FRAME)
@@ -800,11 +812,16 @@
     return 0;
   }
 
+#if CONFIG_SVC_ENCODER
   if (is_frame_droppable(svc, ext_refresh_frame_flags)) return 0;
+#else
+  if (is_frame_droppable(ext_refresh_frame_flags)) return 0;
+#endif  // CONFIG_SVC_ENCODER
 
   int refresh_mask = 0;
 
   if (ext_refresh_frame_flags->update_pending) {
+#if CONFIG_SVC_ENCODER
     if (svc->external_ref_frame_config) {
       for (unsigned int i = 0; i < INTER_REFS_PER_FRAME; i++) {
         int ref_frame_map_idx = svc->ref_idx[i];
@@ -812,6 +829,7 @@
       }
       return refresh_mask;
     }
+#endif  // CONFIG_SVC_ENCODER
     // Unfortunately the encoder interface reflects the old refresh_*_frame
     // flags so we have to replicate the old refresh_frame_flags logic here in
     // order to preserve the behaviour of the flag overrides.
@@ -1448,9 +1466,11 @@
       const int cur_frame_disp =
           cpi->common.current_frame.frame_number + order_offset;
       av1_get_ref_frames(cpi, cur_frame_disp, ref_frame_map_pairs);
+#if CONFIG_SVC_ENCODER
     } else if (cpi->svc.external_ref_frame_config) {
       for (unsigned int i = 0; i < INTER_REFS_PER_FRAME; i++)
         cm->remapped_ref_idx[i] = cpi->svc.ref_idx[i];
+#endif  // CONFIG_SVC_ENCODER
     }
 
     // Get the reference frames
@@ -1560,10 +1580,16 @@
 
   // Leave a signal for a higher level caller about if this frame is droppable
   if (*size > 0) {
-    cpi->droppable = is_frame_droppable(&cpi->svc, &ext_flags->refresh_frame);
+    cpi->droppable = is_frame_droppable(
+#if CONFIG_SVC_ENCODER
+        &cpi->svc,
+#endif  // CONFIG_SVC_ENCODER
+        &ext_flags->refresh_frame);
   }
 
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc) av1_save_layer_context(cpi);
+#endif  // CONFIG_SVC_ENCODER
 
   return AOM_CODEC_OK;
 }
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 8d13ea1..69e6db0 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -392,7 +392,12 @@
 }
 
 void av1_init_seq_coding_tools(SequenceHeader *seq, AV1_COMMON *cm,
-                               const AV1EncoderConfig *oxcf, int use_svc) {
+                               const AV1EncoderConfig *oxcf
+#if CONFIG_SVC_ENCODER
+                               ,
+                               int use_svc
+#endif  // CONFIG_SVC_ENCODER
+) {
   const FrameDimensionCfg *const frm_dim_cfg = &oxcf->frm_dim_cfg;
   const ToolCfg *const tool_cfg = &oxcf->tool_cfg;
 
@@ -406,7 +411,10 @@
   seq->frame_id_numbers_present_flag =
       !(seq->still_picture && seq->reduced_still_picture_hdr) &&
       !oxcf->tile_cfg.enable_large_scale_tile &&
-      tool_cfg->error_resilient_mode && !use_svc;
+#if CONFIG_SVC_ENCODER
+      !use_svc &&
+#endif  // CONFIG_SVC_ENCODER
+      tool_cfg->error_resilient_mode;
   if (seq->still_picture && seq->reduced_still_picture_hdr) {
     seq->order_hint_info.enable_order_hint = 0;
     seq->force_screen_content_tools = 2;
@@ -597,11 +605,13 @@
   cpi->td.counts = &cpi->counts;
 
   // Set init SVC parameters.
+#if CONFIG_SVC_ENCODER
   cpi->use_svc = 0;
   cpi->svc.external_ref_frame_config = 0;
   cpi->svc.non_reference_frame = 0;
   cpi->svc.number_spatial_layers = 1;
   cpi->svc.number_temporal_layers = 1;
+#endif  // CONFIG_SVC_ENCODER
   cm->number_spatial_layers = 1;
   cm->number_temporal_layers = 1;
   cm->spatial_layer_id = 0;
@@ -845,8 +855,12 @@
 
   set_tile_info(cm, &cpi->oxcf.tile_cfg);
 
+#if CONFIG_SVC_ENCODER
   if (!cpi->svc.external_ref_frame_config)
     cpi->ext_flags.refresh_frame.update_pending = 0;
+#else
+  cpi->ext_flags.refresh_frame.update_pending = 0;
+#endif  // CONFIG_SVC_ENCODER
   cpi->ext_flags.refresh_frame_context_pending = 0;
 
   highbd_set_var_fns(cpi);
@@ -858,11 +872,17 @@
         (cm->number_spatial_layers > 1 || cm->number_temporal_layers > 1)
             ? cm->number_spatial_layers * cm->number_temporal_layers - 1
             : 0;
+#if CONFIG_SVC_ENCODER
     av1_init_seq_coding_tools(&cm->seq_params, cm, oxcf, cpi->use_svc);
+#else
+    av1_init_seq_coding_tools(&cm->seq_params, cm, oxcf);
+#endif  // CONFIG_SVC_ENCODER
   }
 
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc)
     av1_update_layer_context_change_config(cpi, rc_cfg->target_bandwidth);
+#endif  // CONFIG_SVC_ENCODER
 
   // restore the value of lag_in_frame for LAP stage.
   if (lap_lag_in_frames != -1) {
@@ -2291,7 +2311,9 @@
 static int encode_without_recode(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   const QuantizationCfg *const q_cfg = &cpi->oxcf.q_cfg;
+#if CONFIG_SVC_ENCODER
   SVC *const svc = &cpi->svc;
+#endif  // CONFIG_SVC_ENCODER
   ResizePendingParams *const resize_pending_params =
       &cpi->resize_pending_params;
   const int resize_pending =
@@ -2301,18 +2323,26 @@
 
   int top_index = 0, bottom_index = 0, q = 0;
   YV12_BUFFER_CONFIG *unscaled = cpi->unscaled_source;
+#if CONFIG_SVC_ENCODER
   InterpFilter filter_scaler =
       cpi->use_svc ? svc->downsample_filter_type[svc->spatial_layer_id]
                    : EIGHTTAP_SMOOTH;
   int phase_scaler =
       cpi->use_svc ? svc->downsample_filter_phase[svc->spatial_layer_id] : 0;
+#else
+  InterpFilter filter_scaler = EIGHTTAP_SMOOTH;
+  int phase_scaler = 0;
+#endif  // CONFIG_SVC_ENCODER
 
   set_size_independent_vars(cpi);
   cpi->source->buf_8bit_valid = 0;
   av1_setup_frame_size(cpi);
   av1_set_size_dependent_vars(cpi, &q, &bottom_index, &top_index);
 
-  if (!cpi->use_svc) {
+#if CONFIG_SVC_ENCODER
+  if (!cpi->use_svc)
+#endif  // CONFIG_SVC_ENCODER
+  {
     phase_scaler = 8;
     // 2:1 scaling.
     if ((cm->width << 1) == unscaled->y_crop_width &&
@@ -2355,13 +2385,16 @@
         phase_scaler, true, false);
   }
 
+#if CONFIG_SVC_ENCODER
   // For 1 spatial layer encoding: if the (non-LAST) reference has different
   // resolution from the source then disable that reference. This is to avoid
   // significant increase in encode time from scaling the references in
   // av1_scale_references. Note GOLDEN is forced to update on the (first/tigger)
   // resized frame and ALTREF will be refreshed ~4 frames later, so both
   // references become available again after few frames.
-  if (svc->number_spatial_layers == 1) {
+  if (svc->number_spatial_layers == 1)
+#endif  // CONFIG_SVC_ENCODER
+  {
     if (cpi->ref_frame_flags & av1_ref_frame_flag_list[GOLDEN_FRAME]) {
       const YV12_BUFFER_CONFIG *const ref =
           get_ref_frame_yv12_buf(cm, GOLDEN_FRAME);
@@ -2379,8 +2412,11 @@
   // For SVC the inter-layer/spatial prediction is not done for newmv
   // (zero_mode is forced), and since the scaled references are only
   // use for newmv search, we can avoid scaling here.
-  if (!frame_is_intra_only(cm) &&
-      !(cpi->use_svc && cpi->svc.force_zero_mode_spatial_ref))
+  if (!frame_is_intra_only(cm)
+#if CONFIG_SVC_ENCODER
+      && !(cpi->use_svc && cpi->svc.force_zero_mode_spatial_ref)
+#endif  // CONFIG_SVC_ENCODER
+  )
     av1_scale_references(cpi, filter_scaler, phase_scaler, 1);
 
   av1_set_quantizer(cm, q_cfg->qm_minlevel, q_cfg->qm_maxlevel, q,
@@ -3207,8 +3243,10 @@
     }
   }
 
+#if CONFIG_SVC_ENCODER
   if (cpi->svc.spatial_layer_id == cpi->svc.number_spatial_layers - 1)
     cpi->svc.num_encoded_top_layer++;
+#endif  // CONFIG_SVC_ENCODER
 
   if (cm->seg.enabled) {
     if (cm->seg.update_map) {
@@ -3572,9 +3610,11 @@
   aom_bitstream_queue_set_frame_write(cm->current_frame.order_hint * 2 +
                                       cm->show_frame);
 #endif
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc && cm->number_spatial_layers > 1) {
     av1_one_pass_cbr_svc_start_layer(cpi);
   }
+#endif  // CONFIG_SVC_ENCODER
 
   cm->showable_frame = 0;
   *size = 0;
@@ -3767,6 +3807,7 @@
   return AOM_CODEC_OK;
 }
 
+#if CONFIG_SVC_ENCODER
 static void svc_set_updates_external_ref_frame_config(
     ExtRefreshFrameFlagsInfo *const ext_refresh_frame_flags, SVC *const svc) {
   ext_refresh_frame_flags->update_pending = 1;
@@ -3793,6 +3834,7 @@
   }
   return ref;
 }
+#endif  // CONFIG_SVC_ENCODER
 
 void av1_apply_encoding_flags(AV1_COMP *cpi, aom_enc_frame_flags_t flags) {
   // TODO(yunqingwang): For what references to use, external encoding flags
@@ -3828,10 +3870,12 @@
 
     av1_use_as_reference(&ext_flags->ref_frame_flags, ref);
   } else {
+#if CONFIG_SVC_ENCODER
     if (cpi->svc.external_ref_frame_config) {
       int ref = svc_set_references_external_ref_frame_config(cpi);
       av1_use_as_reference(&ext_flags->ref_frame_flags, ref);
     }
+#endif  // CONFIG_SVC_ENCODER
   }
 
   if (flags &
@@ -3856,10 +3900,12 @@
     ext_refresh_frame_flags->alt2_ref_frame = (upd & AOM_ALT2_FLAG) != 0;
     ext_refresh_frame_flags->update_pending = 1;
   } else {
+#if CONFIG_SVC_ENCODER
     if (cpi->svc.external_ref_frame_config)
       svc_set_updates_external_ref_frame_config(ext_refresh_frame_flags,
                                                 &cpi->svc);
     else
+#endif  // CONFIG_SVC_ENCODER
       ext_refresh_frame_flags->update_pending = 0;
   }
 
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 603f29f..2a8fd3f 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -44,7 +44,9 @@
 #include "av1/encoder/ratectrl.h"
 #include "av1/encoder/rd.h"
 #include "av1/encoder/speed_features.h"
+#if CONFIG_SVC_ENCODER
 #include "av1/encoder/svc_layercontext.h"
+#endif  // CONFIG_SVC_ENCODER
 #include "av1/encoder/tokenize.h"
 #include "av1/encoder/tpl_model.h"
 #include "av1/encoder/av1_noise_estimate.h"
@@ -2699,6 +2701,7 @@
   TuneVMAFInfo vmaf_info;
 #endif
 
+#if CONFIG_SVC_ENCODER
   /*!
    * Indicates whether to use SVC.
    */
@@ -2707,6 +2710,7 @@
    * Parameters for scalable video coding.
    */
   SVC svc;
+#endif  // CONFIG_SVC_ENCODER
 
   /*!
    * Flag indicating whether look ahead processing (LAP) is enabled.
@@ -2852,8 +2856,13 @@
 void av1_check_initial_width(AV1_COMP *cpi, int use_highbitdepth,
                              int subsampling_x, int subsampling_y);
 
+#if CONFIG_SVC_ENCODER
 void av1_init_seq_coding_tools(SequenceHeader *seq, AV1_COMMON *cm,
                                const AV1EncoderConfig *oxcf, int use_svc);
+#else
+void av1_init_seq_coding_tools(SequenceHeader *seq, AV1_COMMON *cm,
+                               const AV1EncoderConfig *oxcf);
+#endif  // CONFIG_SVC_ENCODER
 
 /*!\endcond */
 
diff --git a/av1/encoder/encoder_alloc.h b/av1/encoder/encoder_alloc.h
index f57169a..bbb2266 100644
--- a/av1/encoder/encoder_alloc.h
+++ b/av1/encoder/encoder_alloc.h
@@ -319,7 +319,9 @@
     aom_free(cpi->level_params.level_info[i]);
   }
 
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc) av1_free_svc_cyclic_refresh(cpi);
+#endif  // CONFIG_SVC_ENCODE
 
   if (cpi->consec_zero_mv) {
     aom_free(cpi->consec_zero_mv);
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index eca53e0..5552329 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -583,7 +583,10 @@
 
   assert(oxcf->tool_cfg.superblock_size == AOM_SUPERBLOCK_SIZE_DYNAMIC);
 
-  if (cpi->svc.number_spatial_layers > 1 ||
+  if (
+#if CONFIG_SVC_ENCODER
+      cpi->svc.number_spatial_layers > 1 ||
+#endif  // CONFIG_SVC_ENCODER
       oxcf->resize_cfg.resize_mode != RESIZE_NONE) {
     // Use the configured size (top resolution) for spatial layers or
     // on resize.
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 993a8bc..f3f70a7 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -264,6 +264,7 @@
   return target;
 }
 
+#if CONFIG_SVC_ENCODER
 // Update the buffer level for higher temporal layers, given the encoded current
 // temporal layer.
 static void update_layer_buffer_level(SVC *svc, int encoded_frame_size) {
@@ -282,6 +283,8 @@
     lrc->buffer_level = lrc->bits_off_target;
   }
 }
+#endif  // CONFIG_SVC_ENCODER
+
 // Update the buffer level: leaky bucket model.
 static void update_buffer_level(AV1_COMP *cpi, int encoded_frame_size) {
   const AV1_COMMON *const cm = &cpi->common;
@@ -297,7 +300,9 @@
   rc->bits_off_target = AOMMIN(rc->bits_off_target, rc->maximum_buffer_size);
   rc->buffer_level = rc->bits_off_target;
 
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc) update_layer_buffer_level(&cpi->svc, encoded_frame_size);
+#endif  // CONFIG_SVC_ENCODER
 }
 
 int av1_rc_get_default_min_gf_interval(int width, int height,
@@ -441,7 +446,10 @@
       (cm->width != cm->prev_frame->width ||
        cm->height != cm->prev_frame->height || change_avg_frame_bandwidth);
   // Apply some control/clamp to QP under certain conditions.
-  if (cm->current_frame.frame_type != KEY_FRAME && !cpi->use_svc &&
+  if (cm->current_frame.frame_type != KEY_FRAME &&
+#if CONFIG_SVC_ENCODER
+      !cpi->use_svc &&
+#endif  // CONFIG_SVC_ENCODER
       rc->frames_since_key > 1 && !change_target_bits_mb &&
       (!cpi->oxcf.rc_cfg.gf_cbr_boost_pct ||
        !(refresh_frame_flags->alt_ref_frame ||
@@ -457,7 +465,10 @@
   }
   // For single spatial layer: if resolution has increased push q closer
   // to the active_worst to avoid excess overshoot.
-  if (cpi->svc.number_spatial_layers <= 1 && cm->prev_frame &&
+  if (cm->prev_frame &&
+#if CONFIG_SVC_ENCODER
+      cpi->svc.number_spatial_layers <= 1 &&
+#endif  // CONFIG_SVC_ENCODER
       (cm->width * cm->height >
        1.5 * cm->prev_frame->width * cm->prev_frame->height))
     q = (q + active_worst_quality) >> 1;
@@ -509,7 +520,10 @@
   } else {
     if ((refresh_frame_flags->alt_ref_frame ||
          refresh_frame_flags->golden_frame) &&
-        !rc->is_src_frame_alt_ref && !cpi->use_svc &&
+        !rc->is_src_frame_alt_ref &&
+#if CONFIG_SVC_ENCODER
+        !cpi->use_svc &&
+#endif  // CONFIG_SVC_ENCODER
         (cpi->oxcf.rc_cfg.mode != AOM_CBR ||
          cpi->oxcf.rc_cfg.gf_cbr_boost_pct > 20))
       rcf = rc->rate_correction_factors[GF_ARF_STD];
@@ -553,7 +567,10 @@
   } else {
     if ((refresh_frame_flags->alt_ref_frame ||
          refresh_frame_flags->golden_frame) &&
-        !rc->is_src_frame_alt_ref && !cpi->use_svc &&
+        !rc->is_src_frame_alt_ref &&
+#if CONFIG_SVC_ENCODER
+        !cpi->use_svc &&
+#endif  // CONFIG_SVC_ENCODER
         (cpi->oxcf.rc_cfg.mode != AOM_CBR ||
          cpi->oxcf.rc_cfg.gf_cbr_boost_pct > 20))
       rc->rate_correction_factors[GF_ARF_STD] = factor;
@@ -909,7 +926,10 @@
       active_best_quality +=
           av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, bit_depth);
     }
-  } else if (!rc->is_src_frame_alt_ref && !cpi->use_svc &&
+  } else if (!rc->is_src_frame_alt_ref &&
+#if CONFIG_SVC_ENCODER
+             !cpi->use_svc &&
+#endif  // CONFIG_SVC_ENCODER
              cpi->oxcf.rc_cfg.gf_cbr_boost_pct &&
              (refresh_frame_flags->golden_frame ||
               refresh_frame_flags->alt_ref_frame)) {
@@ -1817,7 +1837,10 @@
     rc->avg_frame_qindex[KEY_FRAME] =
         ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[KEY_FRAME] + qindex, 2);
   } else {
-    if ((cpi->use_svc && cpi->oxcf.rc_cfg.mode == AOM_CBR) ||
+    if (
+#if CONFIG_SVC_ENCODER
+        (cpi->use_svc && cpi->oxcf.rc_cfg.mode == AOM_CBR) ||
+#endif  // CONFIG_SVC_ENCODER
         (!rc->is_src_frame_alt_ref &&
          !(refresh_frame_flags->golden_frame || is_intrnl_arf ||
            refresh_frame_flags->alt_ref_frame))) {
@@ -2136,6 +2159,7 @@
   } else {
     target = rc->avg_frame_bandwidth;
   }
+#if CONFIG_SVC_ENCODER
   if (cpi->use_svc) {
     // Note that for layers, avg_frame_bandwidth is the cumulative
     // per-frame-bandwidth. For the target size of this frame, use the
@@ -2147,6 +2171,7 @@
     target = lc->avg_frame_size;
     min_frame_target = AOMMAX(lc->avg_frame_size >> 4, FRAME_OVERHEAD_BITS);
   }
+#endif  // CONFIG_SVC_ENCODER
   if (diff > 0) {
     // Lower the target bandwidth for this frame.
     const int pct_low =
diff --git a/av1/encoder/superres_scale.c b/av1/encoder/superres_scale.c
index 541f115..71acd94 100644
--- a/av1/encoder/superres_scale.c
+++ b/av1/encoder/superres_scale.c
@@ -350,12 +350,14 @@
   size_params_type rsz = { frm_dim_cfg->width, frm_dim_cfg->height,
                            SCALE_NUMERATOR };
   int resize_denom = SCALE_NUMERATOR;
+#if CONFIG_SVC_ENCODER
   if (has_no_stats_stage(cpi) && cpi->use_svc &&
       cpi->svc.spatial_layer_id < cpi->svc.number_spatial_layers - 1) {
     rsz.resize_width = cpi->common.width;
     rsz.resize_height = cpi->common.height;
     return rsz;
   }
+#endif  // CONFIG_SVC_ENCODER
   if (is_stat_generation_stage(cpi)) return rsz;
   if (resize_pending_params->width && resize_pending_params->height) {
     rsz.resize_width = resize_pending_params->width;
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index cd7f1cb..7de650c 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -107,6 +107,7 @@
 set_aom_config_var(DECODE_WIDTH_LIMIT 0 "Set limit for decode width.")
 set_aom_config_var(CONFIG_TUNE_VMAF 0 "Enable encoding tuning for VMAF.")
 set_aom_config_var(CONFIG_USE_VMAF_RC 0 "Use libvmaf_rc tune for VMAF_NEG.")
+set_aom_config_var(CONFIG_SVC_ENCODER 0 "Use SVC encoder features.")
 
 # AV1 experiment flags.
 set_aom_config_var(CONFIG_SPEED_STATS 0 "AV1 experiment flag.")
diff --git a/docs.cmake b/docs.cmake
index 697ed0a..4f1f3a4 100644
--- a/docs.cmake
+++ b/docs.cmake
@@ -137,12 +137,16 @@
       "${AOM_ROOT}/av1/encoder/rdopt.h"
       "${AOM_ROOT}/av1/encoder/rdopt.c"
       "${AOM_ROOT}/av1/encoder/speed_features.h"
-      "${AOM_ROOT}/av1/encoder/svc_layercontext.c"
-      "${AOM_ROOT}/av1/encoder/svc_layercontext.h"
       "${AOM_ROOT}/av1/encoder/temporal_filter.h"
       "${AOM_ROOT}/av1/encoder/temporal_filter.c"
       "${AOM_ROOT}/av1/encoder/tpl_model.h"
       "${AOM_ROOT}/av1/encoder/tx_search.h")
+
+  if(CONFIG_SVC_ENCODER)
+    set(AOM_DOXYGEN_SOURCES
+        ${AOM_DOXYGEN_SOURCES} "${AOM_ROOT}/av1/encoder/svc_layercontext.c"
+        "${AOM_ROOT}/av1/encoder/svc_layercontext.h")
+  endif()
 endif()
 
 if(CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h
index 995d3ff..647e944 100644
--- a/test/encode_test_driver.h
+++ b/test/encode_test_driver.h
@@ -115,6 +115,7 @@
     ASSERT_EQ(AOM_CODEC_OK, res) << EncoderError();
   }
 
+#if CONFIG_SVC_ENCODER
   void Control(int ctrl_id, struct aom_svc_layer_id *arg) {
     const aom_codec_err_t res = aom_codec_control(&encoder_, ctrl_id, arg);
     ASSERT_EQ(AOM_CODEC_OK, res) << EncoderError();
@@ -129,6 +130,7 @@
     const aom_codec_err_t res = aom_codec_control(&encoder_, ctrl_id, arg);
     ASSERT_EQ(AOM_CODEC_OK, res) << EncoderError();
   }
+#endif  // CONFIG_SVC_ENCODER
 
   void Control(int ctrl_id, const char *arg) {
     const aom_codec_err_t res = aom_codec_control(&encoder_, ctrl_id, arg);