Fix reallocation for new sps

This works for mnc-dr-dev and later.

Bug: 34779227
Test: re-ran POC before/after patch to verify behavior
Merged-In: Ida0bf6bcc236494c3c89b228039501e287839fbe
Change-Id: Ida0bf6bcc236494c3c89b228039501e287839fbe
(cherry picked from commit 99df61bb9a89cdd123d4f515c44238b48d62642a)
(cherry picked from commit 9bae6dd3b48c15e13ba088102abcf01262552201)
diff --git a/decoder/ihevcd_parse_headers.c b/decoder/ihevcd_parse_headers.c
index afa6de3..10a906b 100644
--- a/decoder/ihevcd_parse_headers.c
+++ b/decoder/ihevcd_parse_headers.c
@@ -1439,12 +1439,16 @@
 
     /* Check if sps_max_dec_pic_buffering or sps_max_num_reorder_pics
        has changed */
-    if(0 != ps_codec->i4_first_pic_done)
+    if(0 != ps_codec->u4_allocate_dynamic_done)
     {
         sps_t *ps_sps_old = ps_codec->s_parse.ps_sps;
         if(ps_sps_old->ai1_sps_max_dec_pic_buffering[ps_sps_old->i1_sps_max_sub_layers - 1] !=
                     ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1])
         {
+            if(0 == ps_codec->i4_first_pic_done)
+            {
+                return IHEVCD_INVALID_PARAMETER;
+            }
             ps_codec->i4_reset_flag = 1;
             return (IHEVCD_ERROR_T)IVD_RES_CHANGED;
         }
@@ -1452,6 +1456,10 @@
         if(ps_sps_old->ai1_sps_max_num_reorder_pics[ps_sps_old->i1_sps_max_sub_layers - 1] !=
                     ps_sps->ai1_sps_max_num_reorder_pics[ps_sps->i1_sps_max_sub_layers - 1])
         {
+            if(0 == ps_codec->i4_first_pic_done)
+            {
+                return IHEVCD_INVALID_PARAMETER;
+            }
             ps_codec->i4_reset_flag = 1;
             return (IHEVCD_ERROR_T)IVD_RES_CHANGED;
         }
@@ -1625,10 +1633,14 @@
         ps_sps->i2_pic_ht_in_min_cb = numerator  /
                         (1 << ps_sps->i1_log2_min_coding_block_size);
     }
-    if((0 != ps_codec->i4_first_pic_done) &&
+    if((0 != ps_codec->u4_allocate_dynamic_done) &&
                     ((ps_codec->i4_wd != ps_sps->i2_pic_width_in_luma_samples) ||
                     (ps_codec->i4_ht != ps_sps->i2_pic_height_in_luma_samples)))
     {
+        if(0 == ps_codec->i4_first_pic_done)
+        {
+            return IHEVCD_INVALID_PARAMETER;
+        }
         ps_codec->i4_reset_flag = 1;
         return (IHEVCD_ERROR_T)IVD_RES_CHANGED;
     }