Remove CONFIG_SCALABILITY

This tool is now fully adopted.

Change-Id: I5ad25f2f134fe371d916e795c4e9f7e41b04888e
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5407fd3..17ef011 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -338,13 +338,11 @@
                  "${AOM_ROOT}/examples/simple_decoder.c"
                  $<TARGET_OBJECTS:aom_common_app_util>
                  $<TARGET_OBJECTS:aom_decoder_app_util>)
-  if (CONFIG_SCALABILITY)
-    add_executable(scalable_decoder
-                   "${AOM_ROOT}/examples/scalable_decoder.c"
-                   $<TARGET_OBJECTS:aom_common_app_util>
-                   $<TARGET_OBJECTS:aom_decoder_app_util>)
-  endif ()
-
+  add_executable(scalable_decoder
+                 "${AOM_ROOT}/examples/scalable_decoder.c"
+                 $<TARGET_OBJECTS:aom_common_app_util>
+                 $<TARGET_OBJECTS:aom_decoder_app_util>)
+  
   if (CONFIG_ANALYZER)
     add_executable(analyzer
                    "${AOM_ROOT}/examples/analyzer.cc"
@@ -384,11 +382,9 @@
   set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
       aomdec decode_to_md5 decode_with_drops simple_decoder)
 
-  if (CONFIG_SCALABILITY)
     set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
         scalable_decoder)
-  endif ()
-
+  
   # Add decoder examples to the app targets list.
   set(AOM_APP_TARGETS ${AOM_APP_TARGETS} ${AOM_DECODER_EXAMPLE_TARGETS})
 endif ()
@@ -422,21 +418,17 @@
                      $<TARGET_OBJECTS:aom_common_app_util>
                      $<TARGET_OBJECTS:aom_encoder_app_util>)
     endif ()
-    if (CONFIG_SCALABILITY)
       add_executable(scalable_encoder
                      "${AOM_ROOT}/examples/scalable_encoder.c"
                      $<TARGET_OBJECTS:aom_common_app_util>
                      $<TARGET_OBJECTS:aom_encoder_app_util>)
-    endif ()
 
     # Maintain a list of encoder example targets.
     set(AOM_ENCODER_EXAMPLE_TARGETS
         aomenc lossless_encoder noise_model set_maps simple_encoder twopass_encoder)
 
-    if (CONFIG_SCALABILITY)
       set(AOM_ENCODER_EXAMPLE_TARGETS ${AOM_ENCODER_EXAMPLE_TARGETS}
           scalable_encoder)
-    endif ()
 
   endif ()
 
diff --git a/aomdec.c b/aomdec.c
index 29951b2..b765335 100644
--- a/aomdec.c
+++ b/aomdec.c
@@ -243,13 +243,8 @@
       return ivf_read_frame(input->aom_input_ctx->file, buf, bytes_in_buffer,
                             buffer_size);
     case FILE_TYPE_OBU:
-      return obudec_read_temporal_unit(input->obu_ctx, buf,
-#if CONFIG_SCALABILITY
-                                       bytes_in_buffer, buffer_size, 0
-#else
-                                       bytes_in_buffer, buffer_size
-#endif
-      );
+      return obudec_read_temporal_unit(input->obu_ctx, buf, bytes_in_buffer,
+                                       buffer_size, 0);
     default: return 1;
   }
 }
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index d1a0fa8..cee91e4 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -26,10 +26,7 @@
 
 #define MAG_SIZE (4)
 #define MAX_INDEX_SIZE (256)
-
-#if CONFIG_SCALABILITY
 #define MAX_NUM_ENHANCEMENT_LAYERS 128
-#endif
 
 struct av1_extracfg {
   int cpu_used;  // available cpu percentage in 1/16
@@ -1299,10 +1296,8 @@
       pkt.data.frame.partition_id = -1;
 
       int write_temporal_delimiter = 1;
-#if CONFIG_SCALABILITY
       // only write OBU_TD if base layer
       write_temporal_delimiter = !cpi->common.enhancement_layer_id;
-#endif  // CONFIG_SCALABILITY
       if (write_temporal_delimiter) {
         // move data and insert OBU_TD preceded by optional 4 byte size
         uint32_t obu_header_size = 1;
@@ -1496,32 +1491,20 @@
 
 static aom_codec_err_t ctrl_set_enhancement_layer_id(aom_codec_alg_priv_t *ctx,
                                                      va_list args) {
-#if CONFIG_SCALABILITY
   const int enhancement_layer_id = va_arg(args, int);
   if (enhancement_layer_id > MAX_NUM_ENHANCEMENT_LAYERS)
     return AOM_CODEC_INVALID_PARAM;
   ctx->cpi->common.enhancement_layer_id = enhancement_layer_id;
   return AOM_CODEC_OK;
-#else
-  (void)ctx;
-  (void)args;
-  return AOM_CODEC_UNSUP_FEATURE;
-#endif
 }
 
 static aom_codec_err_t ctrl_set_number_spatial_layers(aom_codec_alg_priv_t *ctx,
                                                       va_list args) {
-#if CONFIG_SCALABILITY
   const int number_spatial_layers = va_arg(args, int);
   if (number_spatial_layers > MAX_NUM_ENHANCEMENT_LAYERS)
     return AOM_CODEC_INVALID_PARAM;
   ctx->cpi->common.enhancement_layers_cnt = number_spatial_layers - 1;
   return AOM_CODEC_OK;
-#else
-  (void)ctx;
-  (void)args;
-  return AOM_CODEC_UNSUP_FEATURE;
-#endif
 }
 
 static aom_codec_err_t ctrl_set_tune_content(aom_codec_alg_priv_t *ctx,
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index e5d56bd..8edf2f9 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -205,16 +205,8 @@
   // if (obu_type != OBU_SEQUENCE_HEADER)
   //   return AOM_CODEC_INVALID_PARAM;
 
-  av1_read_profile(&rb);  // profile
-#if !CONFIG_SCALABILITY
+  av1_read_profile(&rb);        // profile
   aom_rb_read_literal(&rb, 4);  // level
-#else
-  int i;
-  si->enhancement_layers_cnt = aom_rb_read_literal(&rb, 2);
-  for (i = 0; i <= (int)si->enhancement_layers_cnt; i++) {
-    aom_rb_read_literal(&rb, 4);  // level for each enhancement layer
-  }
-#endif  // CONFIG_SCALABILITY
 
   int num_bits_width = aom_rb_read_literal(&rb, 4) + 1;
   int num_bits_height = aom_rb_read_literal(&rb, 4) + 1;
@@ -620,10 +612,8 @@
 
           ctx->img.fb_priv = frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
           img = &ctx->img;
-#if CONFIG_SCALABILITY
           img->temporal_id = cm->temporal_layer_id;
           img->enhancement_id = cm->enhancement_layer_id;
-#endif
 #if CONFIG_FILM_GRAIN
           return add_grain_if_needed(
               img, ctx->image_with_grain,
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 3183136..461c876 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -69,14 +69,10 @@
 #define NUM_PING_PONG_BUFFERS 2
 
 #if CONFIG_OPERATING_POINTS
-#if CONFIG_SCALABILITY
 #define MAX_NUM_TEMPORAL_LAYERS 8
 #define MAX_NUM_SPATIAL_LAYERS 4
 #define MAX_NUM_OPERATING_POINTS \
   MAX_NUM_TEMPORAL_LAYERS + MAX_NUM_SPATIAL_LAYERS
-#else
-#define MAX_NUM_OPERATING_POINTS 1
-#endif
 #endif
 
 // TODO(jingning): Turning this on to set up transform coefficient
@@ -546,12 +542,9 @@
   // TODO(jingning): This can be combined with sign_bias later.
   int8_t ref_frame_side[REF_FRAMES];
   int frame_refs_short_signaling;
-
-#if CONFIG_SCALABILITY
   int temporal_layer_id;
   int enhancement_layer_id;
   int enhancement_layers_cnt;
-#endif
 
 #if TXCOEFF_TIMER
   int64_t cum_txcoeff_timer;
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c
index fb48960..22c1a9f 100644
--- a/av1/decoder/obu.c
+++ b/av1/decoder/obu.c
@@ -22,7 +22,6 @@
 #include "av1/decoder/decodeframe.h"
 #include "av1/decoder/obu.h"
 
-#if CONFIG_SCALABILITY
 // Picture prediction structures (0-12 are predefined) in scalability metadata.
 typedef enum {
   SCALABILITY_L1T2 = 0,
@@ -40,7 +39,6 @@
   SCALABILITY_S2T3h = 12,
   SCALABILITY_SS = 13
 } SCALABILITY_STRUCTURES;
-#endif
 
 int get_obu_type(uint8_t obu_header, OBU_TYPE *obu_type) {
   if (!obu_type) return -1;
@@ -153,22 +151,14 @@
   cm->profile = av1_read_profile(rb);
 
 #if !CONFIG_OPERATING_POINTS
-#if !CONFIG_SCALABILITY
-  aom_rb_read_literal(rb, 4);  // level
-#else
   int i;
   pbi->common.enhancement_layers_cnt = aom_rb_read_literal(rb, 2);
   for (i = 0; i <= pbi->common.enhancement_layers_cnt; i++) {
     aom_rb_read_literal(rb, 4);  // level for each enhancement layer
   }
-#endif
-#else  // CONFIG_OPERATING_POINTS
-#if CONFIG_SCALABILITY
+#else   // CONFIG_OPERATING_POINTS
   uint8_t operating_points_minus1_cnt = aom_rb_read_literal(rb, 5);
   pbi->common.enhancement_layers_cnt = operating_points_minus1_cnt + 1;
-#else
-  uint8_t operating_points_minus1_cnt = 0;
-#endif
   int i;
   SequenceHeader *seq_params = &cm->seq_params;
   for (i = 0; i < operating_points_minus1_cnt + 1; i++) {
@@ -317,7 +307,6 @@
   mem_get_le16(data);
 }
 
-#if CONFIG_SCALABILITY
 static void scalability_structure(struct aom_read_bit_buffer *rb) {
   int enhancement_layers_cnt = aom_rb_read_literal(rb, 2);
   int enhancement_layer_dimensions_present_flag = aom_rb_read_literal(rb, 1);
@@ -360,7 +349,6 @@
     scalability_structure(&rb);
   }
 }
-#endif
 
 static size_t read_metadata(const uint8_t *data, size_t sz) {
   if (sz < 2) return sz;  // Invalid data size.
@@ -372,10 +360,8 @@
     read_metadata_hdr_cll(data + 2);
   } else if (metadata_type == OBU_METADATA_TYPE_HDR_MDCV) {
     read_metadata_hdr_mdcv(data + 2);
-#if CONFIG_SCALABILITY
   } else if (metadata_type == OBU_METADATA_TYPE_SCALABILITY) {
     read_metadata_scalability(data + 2, sz - 2);
-#endif
   }
 
   return sz;
@@ -453,10 +439,8 @@
       return;
     }
 
-#if CONFIG_SCALABILITY
     cm->temporal_layer_id = obu_header.temporal_layer_id;
     cm->enhancement_layer_id = obu_header.enhancement_layer_id;
-#endif
 
     switch (obu_header.type) {
       case OBU_TEMPORAL_DELIMITER:
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 0688b51..0f4e3c2 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3375,13 +3375,8 @@
 }
 #endif
 
-static uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst
-#if CONFIG_SCALABILITY
-                                          ,
+static uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst,
                                           uint8_t enhancement_layers_cnt) {
-#else
-) {
-#endif
   AV1_COMMON *const cm = &cpi->common;
   struct aom_write_bit_buffer wb = { dst, 0 };
   uint32_t size = 0;
@@ -3389,21 +3384,13 @@
   write_profile(cm->profile, &wb);
 
 #if !CONFIG_OPERATING_POINTS
-#if !CONFIG_SCALABILITY
-  aom_wb_write_literal(&wb, 0, 4);
-#else
   aom_wb_write_literal(&wb, enhancement_layers_cnt, 2);
   int i;
   for (i = 0; i <= enhancement_layers_cnt; i++) {
     aom_wb_write_literal(&wb, 0, 4);
   }
-#endif
-#else  // CONFIG_OPERATING_POINTS
-#if !CONFIG_SCALABILITY
-  uint8_t operating_points_minus1_cnt = 0;
-#else
+#else   // CONFIG_OPERATING_POINTS
   uint8_t operating_points_minus1_cnt = enhancement_layers_cnt;
-#endif
   aom_wb_write_literal(&wb, operating_points_minus1_cnt, 5);
   int i;
   for (i = 0; i < operating_points_minus1_cnt + 1; i++) {
@@ -3830,13 +3817,9 @@
   uint32_t obu_header_size = 0;
   uint32_t obu_payload_size = 0;
   FrameHeaderInfo fh_info = { NULL, 0, 0 };
-#if CONFIG_SCALABILITY
   const uint8_t enhancement_layers_cnt = cm->enhancement_layers_cnt;
   const uint8_t obu_extension_header =
       cm->temporal_layer_id << 5 | cm->enhancement_layer_id << 3 | 0;
-#else
-  uint8_t obu_extension_header = 0;
-#endif  // CONFIG_SCALABILITY
 
 #if CONFIG_BITSTREAM_DEBUG
   bitstream_queue_reset_write();
@@ -3848,13 +3831,8 @@
   if (cm->frame_type == KEY_FRAME) {
     obu_header_size = write_obu_header(OBU_SEQUENCE_HEADER, 0, data);
 
-#if CONFIG_SCALABILITY
     obu_payload_size = write_sequence_header_obu(cpi, data + obu_header_size,
                                                  enhancement_layers_cnt);
-#else
-    obu_payload_size = write_sequence_header_obu(cpi, data + obu_header_size);
-#endif  // CONFIG_SCALABILITY
-
     const size_t length_field_size =
         obu_memmove(obu_header_size, obu_payload_size, data);
     if (write_uleb_obu_size(obu_header_size, obu_payload_size, data) !=
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 5a186a9..47c8fb1 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -101,6 +101,5 @@
 set(CONFIG_OBU_REDUNDANT_FRAME_HEADER 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_OPERATING_POINTS 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_RD_DEBUG 0 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_SCALABILITY 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_TRAILING_BITS 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_FILEOPTIONS 1 CACHE NUMBER "AV1 config option flag.")
diff --git a/build/cmake/aom_experiment_deps.cmake b/build/cmake/aom_experiment_deps.cmake
index b06b553..df05c2b 100644
--- a/build/cmake/aom_experiment_deps.cmake
+++ b/build/cmake/aom_experiment_deps.cmake
@@ -30,12 +30,6 @@
     change_config_and_warn(CONFIG_RD_DEBUG 0 CONFIG_JNT_COMP)
   endif()
 
-  if (CONFIG_FRAME_COUNTER_FOR_SCALABILITY)
-    if (NOT CONFIG_SCALABILITY)
-      change_config_and_warn(CONFIG_SCALABILITY 1
-                             CONFIG_FRAME_COUNTER_FOR_SCALABILITY)
-    endif ()
-  endif()
 endmacro ()
 
 endif ()  # AOM_BUILD_CMAKE_AOM_EXPERIMENT_DEPS_CMAKE_
diff --git a/docs.cmake b/docs.cmake
index aa4cf16..78281f2 100644
--- a/docs.cmake
+++ b/docs.cmake
@@ -89,7 +89,6 @@
       "Simplified encoder loop."
       "Two-pass encoder loop.")
 
-  if (CONFIG_SCALABILITY)
     set(AOM_DOXYGEN_EXAMPLE_SOURCES
         ${AOM_DOXYGEN_EXAMPLE_SOURCES}
         "${AOM_ROOT}/examples/scalable_encoder.c")
@@ -97,7 +96,6 @@
     set(AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS
         ${AOM_DOXYGEN_EXAMPLE_DESCRIPTIONS}
         "Scalable encoder loop.")
-  endif ()
 
   set(AOM_DOXYGEN_SECTIONS ${AOM_DOXYGEN_SECTIONS} "av1_encoder encoder")
 
diff --git a/examples/scalable_decoder.c b/examples/scalable_decoder.c
index aba6532..3586df6 100644
--- a/examples/scalable_decoder.c
+++ b/examples/scalable_decoder.c
@@ -79,9 +79,7 @@
 #include "../tools_common.h"
 #include "../video_reader.h"
 #include "./aom_config.h"
-#if CONFIG_SCALABILITY
 #include "./obudec.h"
-#endif
 
 static const char *exec_name;
 
diff --git a/obudec.c b/obudec.c
index 689855e..4d035c1 100644
--- a/obudec.c
+++ b/obudec.c
@@ -235,12 +235,7 @@
 
 int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
                               uint8_t **buffer, size_t *bytes_read,
-#if CONFIG_SCALABILITY
-                              size_t *buffer_size, int last_layer_id
-#else
-                              size_t *buffer_size
-#endif
-) {
+                              size_t *buffer_size, int last_layer_id) {
   FILE *f = obu_ctx->avx_ctx->file;
   if (!f) return -1;
 
@@ -264,12 +259,9 @@
       return -1;
     }
 
-    if (obu_header.type == OBU_TEMPORAL_DELIMITER || obu_size == 0
-#if CONFIG_SCALABILITY
-        || (obu_header.has_extension &&
-            obu_header.enhancement_layer_id > last_layer_id)
-#endif
-    ) {
+    if (obu_header.type == OBU_TEMPORAL_DELIMITER || obu_size == 0 ||
+        (obu_header.has_extension &&
+         obu_header.enhancement_layer_id > last_layer_id)) {
       const size_t tu_size = obu_ctx->bytes_buffered;
 
 #if defined AOM_MAX_ALLOCABLE_MEMORY
diff --git a/obudec.h b/obudec.h
index e80dfd7..158202e 100644
--- a/obudec.h
+++ b/obudec.h
@@ -35,12 +35,7 @@
 // via 'bytes_read'.
 int obudec_read_temporal_unit(struct ObuDecInputContext *obu_ctx,
                               uint8_t **buffer, size_t *bytes_read,
-#if CONFIG_SCALABILITY
-                              size_t *buffer_size, int last_layer_id
-#else
-                              size_t *buffer_size
-#endif
-);
+                              size_t *buffer_size, int last_layer_id);
 
 void obudec_free(struct ObuDecInputContext *obu_ctx);
 
diff --git a/tools/dump_obu.cc b/tools/dump_obu.cc
index 3460fe2..63b5f1e 100644
--- a/tools/dump_obu.cc
+++ b/tools/dump_obu.cc
@@ -24,10 +24,7 @@
 
 namespace {
 
-#if CONFIG_SCALABILITY
 const int kIgnoreLayers = 8;  // Used to ignore layer info in obudec.
-#endif
-
 const size_t kInitialBufferSize = 100 * 1024;
 
 struct InputContext {
@@ -77,12 +74,7 @@
     }
     case FILE_TYPE_OBU: {
       if (obudec_read_temporal_unit(ctx->obu_ctx, &ctx->unit_buffer, unit_size,
-#if CONFIG_SCALABILITY
-                                    &ctx->unit_buffer_size, kIgnoreLayers
-#else
-                                    &ctx->unit_buffer_size
-#endif
-                                    )) {
+                                    &ctx->unit_buffer_size, kIgnoreLayers)) {
         return false;
       }
       break;