[NORMATIVE] Align scalability implementation with spec

BUG=aomedia:1526

Change-Id: I0cb75f285ff59cd5edbaf3c6b80156312b4db584
diff --git a/av1/av1_dx_iface.c b/av1/av1_dx_iface.c
index da49e9b..f375922 100644
--- a/av1/av1_dx_iface.c
+++ b/av1/av1_dx_iface.c
@@ -213,12 +213,13 @@
   // if (obu_type != OBU_SEQUENCE_HEADER)
   //   return AOM_CODEC_INVALID_PARAM;
 
-  av1_read_profile(&rb);        // profile
+  av1_read_profile(&rb);  // profile
+#if !CONFIG_SCALABILITY
   aom_rb_read_literal(&rb, 4);  // level
-#if CONFIG_SCALABILITY
+#else
   int i;
   si->enhancement_layers_cnt = aom_rb_read_literal(&rb, 2);
-  for (i = 1; i <= (int)si->enhancement_layers_cnt; i++) {
+  for (i = 0; i <= (int)si->enhancement_layers_cnt; i++) {
     aom_rb_read_literal(&rb, 4);  // level for each enhancement layer
   }
 #endif  // CONFIG_SCALABILITY
diff --git a/av1/decoder/obu.c b/av1/decoder/obu.c
index 565be02..4b71604 100644
--- a/av1/decoder/obu.c
+++ b/av1/decoder/obu.c
@@ -150,16 +150,14 @@
                                          struct aom_read_bit_buffer *rb) {
   AV1_COMMON *const cm = &pbi->common;
   uint32_t saved_bit_offset = rb->bit_offset;
-#if CONFIG_SCALABILITY
-  int i;
-#endif
 
   cm->profile = av1_read_profile(rb);
+#if !CONFIG_SCALABILITY
   aom_rb_read_literal(rb, 4);  // level
-
-#if CONFIG_SCALABILITY
+#else
+  int i;
   pbi->common.enhancement_layers_cnt = aom_rb_read_literal(rb, 2);
-  for (i = 1; i <= pbi->common.enhancement_layers_cnt; i++) {
+  for (i = 0; i <= pbi->common.enhancement_layers_cnt; i++) {
     aom_rb_read_literal(rb, 4);  // level for each enhancement layer
   }
 #endif
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index da68477..89a9150 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3530,12 +3530,12 @@
   uint32_t size = 0;
 
   write_profile(cm->profile, &wb);
-
+#if !CONFIG_SCALABILITY
   aom_wb_write_literal(&wb, 0, 4);
-#if CONFIG_SCALABILITY
+#else
   aom_wb_write_literal(&wb, enhancement_layers_cnt, 2);
   int i;
-  for (i = 1; i <= enhancement_layers_cnt; i++) {
+  for (i = 0; i <= enhancement_layers_cnt; i++) {
     aom_wb_write_literal(&wb, 0, 4);
   }
 #endif