Snap for 5457264 from 9c27c43dd7ce98a6712f002bcf9590bcbeb3e1bb to qt-release

Change-Id: Ia0e47e90d6c224790e96faedea1c8debca9ba137
diff --git a/decoder/ixheaacd_create.c b/decoder/ixheaacd_create.c
index b5d65cf..962b98c 100644
--- a/decoder/ixheaacd_create.c
+++ b/decoder/ixheaacd_create.c
@@ -540,7 +540,6 @@
                               WORD32 tracks_for_decoder) {
   WORD32 stream;
 
-  WORD32 num_delay_samp = 0;
   WORD32 err = 0;
   ia_frame_data_struct *pstr_frame_data;
   WORD32 stream_count;
@@ -558,6 +557,8 @@
         err = ixheaacd_dec_data_init(handle, pstr_frame_data,
                                      &(pstr_dec_data->str_usac_data));
 
+        if (err != 0) return err;
+
         switch (pstr_dec_data->str_usac_data.sbr_ratio_idx) {
           case 0:
             handle->aac_config.ui_sbr_mode = 0;
@@ -576,7 +577,6 @@
             handle->aac_config.ui_sbr_mode = 0;
         }
 
-        if (err != 0) return err;
 
         break;
 
@@ -700,6 +700,6 @@
       }
     }
   }
-
-  return (num_delay_samp);
+  aac_dec_handle->decode_create_done = 1;
+  return 0;
 }
diff --git a/decoder/ixheaacd_decode_main.c b/decoder/ixheaacd_decode_main.c
index 0a411f3..8bb71da 100644
--- a/decoder/ixheaacd_decode_main.c
+++ b/decoder/ixheaacd_decode_main.c
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ixheaacd_type_def.h>
-#include <ixheaacd_type_def.h>
+#include "ixheaacd_error_standards.h"
 #include "ixheaacd_memory_standards.h"
 #include "ixheaacd_sbrdecsettings.h"
 #include "ixheaacd_env_extr_part.h"
@@ -263,12 +263,14 @@
 
     if (frames_done == 0) {
       WORD32 delay;
-      delay = ixheaacd_decode_create(
-          handle, pstr_dec_data,
-          pstr_dec_data->str_frame_data.scal_out_select + 1);
+      if (aac_dec_handle->decode_create_done == 0) {
+        delay = ixheaacd_decode_create(
+            handle, pstr_dec_data,
+            pstr_dec_data->str_frame_data.scal_out_select + 1);
+        if (delay == -1) return -1;
+      }
       pstr_dec_data->dec_bit_buf.max_size =
           handle->p_mem_info_aac[IA_MEMTYPE_INPUT].ui_size;
-      if (delay == -1) return -1;
       *num_channel_out = pstr_dec_data->str_frame_data.scal_out_num_channels;
       return 0;
     }
@@ -315,6 +317,7 @@
         if (suitable_tracks <= 0) return -1;
 
         /* call codec re-configure*/
+        aac_dec_handle->decode_create_done = 0;
         err = ixheaacd_config(
             &config_bit_buf, &(pstr_dec_data->str_frame_data
                                    .str_audio_specific_config.str_usac_config),
@@ -326,7 +329,6 @@
             .sampling_frequency =
             pstr_dec_data->str_frame_data.str_audio_specific_config
                 .str_usac_config.usac_sampling_frequency;
-
         delay = ixheaacd_decode_create(
             handle, pstr_dec_data,
             pstr_dec_data->str_frame_data.scal_out_select + 1);
@@ -357,6 +359,7 @@
       }
 
       // temp_read=ixheaacd_show_bits_buf(pstr_dec_data->dec_bit_buf,preroll_frame_offset[access_unit]);
+      if (!aac_dec_handle->decode_create_done) return IA_FATAL_ERROR;
 
       err =
           ixheaacd_usac_process(pstr_dec_data, num_channel_out, aac_dec_handle);
diff --git a/decoder/ixheaacd_struct_def.h b/decoder/ixheaacd_struct_def.h
index ef67415..ee52f0c 100644
--- a/decoder/ixheaacd_struct_def.h
+++ b/decoder/ixheaacd_struct_def.h
@@ -233,6 +233,7 @@
   WORD32 header_length;
   ia_sbr_header_data_struct str_sbr_config;
   jmp_buf xaac_jmp_buf;
+  WORD32 decode_create_done;
 } ia_aac_dec_state_struct;
 
 typedef struct ia_exhaacplus_dec_api_struct {