Decoder bug fixes (#60)

* Fix for divide-by-zero in ixheaacd_sbr_env_calc

These changes handle the divide-by-zero runtime error reported
while calculating the energy because the consecutive frequency bands
were coming same.

Bug: ossFuzz:63038
Test: poc in bug

* Fix for divide-by-zero in ixheaacd_calc_stop_band

These changes handle the divide-by-zero runtime error reported
because sampling frequency comes out to be zero.

Bug: ossFuzz:63138
Test: poc in bug
diff --git a/decoder/ixheaacd_create.c b/decoder/ixheaacd_create.c
index 918d84f..4866fe1 100644
--- a/decoder/ixheaacd_create.c
+++ b/decoder/ixheaacd_create.c
@@ -394,7 +394,9 @@
       &usac_data->ccfl, &usac_data->output_samples,
       &pstr_frame_data->str_layer.sample_rate_layer,
       &layer_config->samp_frequency_index);
-
+  if (!pstr_frame_data->str_layer.sample_rate_layer) {
+    return -1;
+  }
   pstr_stream_config->sampling_frequency =
       pstr_frame_data->str_layer.sample_rate_layer;
   pstr_stream_config->samp_frequency_index = layer_config->samp_frequency_index;
diff --git a/decoder/ixheaacd_esbr_envcal.c b/decoder/ixheaacd_esbr_envcal.c
index 677c616..f5aa413 100644
--- a/decoder/ixheaacd_esbr_envcal.c
+++ b/decoder/ixheaacd_esbr_envcal.c
@@ -329,11 +329,13 @@
             c++;
           }
 
-          if (!int_mode) {
+          if (!int_mode && ui != li) {
             for (nrg = 0, k = c - (ui - li); k < c; k++) {
               nrg += nrg_est_pvc[k][t];
             }
             nrg /= (ui - li);
+          } else {
+            nrg = 0;
           }
           c -= (ui - li);
 
@@ -453,11 +455,13 @@
             c++;
           }
 
-          if (!int_mode) {
+          if (!int_mode && ui != li) {
             for (nrg = 0, k = c - (ui - li); k < c; k++) {
               nrg += nrg_est_pvc[k][t];
             }
             nrg /= (ui - li);
+          } else {
+            nrg = 0;
           }
           c -= (ui - li);
 
@@ -669,11 +673,13 @@
                 rate * p_frame_info->border_vec[i]);
             }
           }
-          if (!int_mode) {
+          if (!int_mode && ui != li) {
             for (nrg = 0, k = c - (ui - li); k < c; k++) {
               nrg += nrg_est[k];
             }
             nrg /= (ui - li);
+          } else {
+            nrg = 0;
           }
           c -= (ui - li);