Decoder: Fix slice number increment for error clips

Bug: 28673410
diff --git a/decoder/ih264d_api.c b/decoder/ih264d_api.c
index e2fa322..bcdd376 100644
--- a/decoder/ih264d_api.c
+++ b/decoder/ih264d_api.c
@@ -1901,6 +1901,7 @@
     ps_dec->u4_dec_thread_created = 0;
     ps_dec->u4_bs_deblk_thread_created = 0;
     ps_dec->u4_cur_bs_mb_num = 0;
+    ps_dec->u4_start_recon_deblk  = 0;
 
     DEBUG_THREADS_PRINTF(" Starting process call\n");
 
diff --git a/decoder/ih264d_parse_headers.c b/decoder/ih264d_parse_headers.c
index 94ec8a8..1d97071 100644
--- a/decoder/ih264d_parse_headers.c
+++ b/decoder/ih264d_parse_headers.c
@@ -1038,6 +1038,12 @@
                 H264_DEC_DEBUG_PRINT("\nForbidden bit set in Nal Unit, Let's try\n");
             }
             u1_nal_unit_type = NAL_UNIT_TYPE(u1_first_byte);
+            // if any other nal unit other than slice nal is encountered in between a
+            // frame break out of loop without consuming header
+            if((ps_dec->u2_total_mbs_coded != 0) && (u1_nal_unit_type > IDR_SLICE_NAL))
+            {
+                return ERROR_INCOMPLETE_FRAME;
+            }
             ps_dec->u1_nal_unit_type = u1_nal_unit_type;
             u1_nal_ref_idc = (UWORD8)(NAL_REF_IDC(u1_first_byte));
             //Skip all NALUs if SPS and PPS are not decoded
diff --git a/decoder/ih264d_parse_pslice.c b/decoder/ih264d_parse_pslice.c
index a589d84..ca5c393 100644
--- a/decoder/ih264d_parse_pslice.c
+++ b/decoder/ih264d_parse_pslice.c
@@ -1550,6 +1550,7 @@
                 }
             }
         }
+        ps_dec->u4_first_slice_in_pic = 0;
     }
     else
     {
@@ -1842,11 +1843,13 @@
 
     H264_DEC_DEBUG_PRINT("Mbs in slice: %d\n", ps_dec->ps_cur_slice->u4_mbs_in_slice);
 
-    ps_dec->u2_cur_slice_num++;
 
     /* incremented here only if first slice is inserted */
     if(ps_dec->u4_first_slice_in_pic != 0)
+    {
         ps_dec->ps_parse_cur_slice++;
+        ps_dec->u2_cur_slice_num++;
+    }
 
     ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
     ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index 5ff92f8..73bc45d 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -374,6 +374,7 @@
     ps_dec->ps_parse_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
     ps_dec->ps_decode_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
     ps_dec->ps_computebs_cur_slice = &(ps_dec->ps_dec_slice_buf[0]);
+    ps_dec->u2_cur_slice_num = 0;
 
     /* Initialize all the HP toolsets to zero */
     ps_dec->s_high_profile.u1_scaling_present = 0;
@@ -573,7 +574,6 @@
     ps_dec->u2_mv_2mb[1] = 0;
     ps_dec->u1_last_pic_not_decoded = 0;
 
-    ps_dec->u2_cur_slice_num = 0;
     ps_dec->u2_cur_slice_num_dec_thread = 0;
     ps_dec->u2_cur_slice_num_bs = 0;
     ps_dec->u4_intra_pred_line_ofst = 0;
@@ -1425,7 +1425,10 @@
     }
 
     if (ps_dec->u4_first_slice_in_pic == 0)
+    {
         ps_dec->ps_parse_cur_slice++;
+        ps_dec->u2_cur_slice_num++;
+    }
 
     ps_dec->u1_slice_header_done = 0;
 
@@ -1908,7 +1911,6 @@
     if(ret != OK)
         return ret;
 
-    ps_dec->u2_cur_slice_num++;
     /* storing last Mb X and MbY of the slice */
     ps_dec->i2_prev_slice_mbx = ps_dec->u2_mbx;
     ps_dec->i2_prev_slice_mby = ps_dec->u2_mby;