[Video, Svc] Remove inactive spatial layers in codec initializer

This is more logical way to remove inactive lower layers.
Current way is to notify the encoder that the layer is inactive,
then renumber layers at the packatization level.

This Cl will allow to simplify libvpx vp9 encoder, svcRateAllocator and
vp9 packetizer.

Bug: webrtc:11319
Change-Id: Idf0bb30b729f5ecc97e31454b32934546b681aa2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173182
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31058}
diff --git a/modules/video_coding/video_codec_initializer.cc b/modules/video_coding/video_codec_initializer.cc
index bd40385..e8665b9 100644
--- a/modules/video_coding/video_codec_initializer.cc
+++ b/modules/video_coding/video_codec_initializer.cc
@@ -179,19 +179,18 @@
         // Layering is set explicitly.
         spatial_layers = config.spatial_layers;
       } else {
-        size_t min_required_layers = 0;
-        // Need at least enough layers for the first active one to be present.
+        size_t first_active_layer = 0;
         for (size_t spatial_idx = 0;
              spatial_idx < config.simulcast_layers.size(); ++spatial_idx) {
           if (config.simulcast_layers[spatial_idx].active) {
-            min_required_layers = spatial_idx + 1;
+            first_active_layer = spatial_idx;
             break;
           }
         }
 
         spatial_layers = GetSvcConfig(
             video_codec.width, video_codec.height, video_codec.maxFramerate,
-            min_required_layers, video_codec.VP9()->numberOfSpatialLayers,
+            first_active_layer, video_codec.VP9()->numberOfSpatialLayers,
             video_codec.VP9()->numberOfTemporalLayers,
             video_codec.mode == VideoCodecMode::kScreensharing);
 
@@ -210,7 +209,7 @@
              spatial_idx < config.simulcast_layers.size() &&
              spatial_idx < spatial_layers.size();
              ++spatial_idx) {
-          spatial_layers[spatial_idx].active =
+          spatial_layers[spatial_idx - first_active_layer].active =
               config.simulcast_layers[spatial_idx].active;
         }
       }