Merge the 2021-09-05 SPL branch from AOSP-Partner

* security-aosp-pi-release:
  Decoder: Update check for increment u2_cur_slice_num

Change-Id: I25b6cc3b7dc32c0b7b14cb100d0e7f1adf5f66d3
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index cf2dda9..ffe7f2b 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -1476,17 +1476,20 @@
         i1_is_end_of_poc = 0;
     }
 
-    if (ps_dec->u4_first_slice_in_pic == 0)
+    /* Increment only if the current slice has atleast 1 more MB */
+    if (ps_dec->u4_first_slice_in_pic == 0 &&
+        (ps_dec->ps_parse_cur_slice->u4_first_mb_in_slice <
+        (UWORD32)(ps_dec->u2_total_mbs_coded >> ps_dec->ps_cur_slice->u1_mbaff_frame_flag)))
     {
         ps_dec->ps_parse_cur_slice++;
         ps_dec->u2_cur_slice_num++;
+        // in the case of single core increment ps_decode_cur_slice
+        if(ps_dec->u1_separate_parse == 0)
+        {
+            ps_dec->ps_decode_cur_slice++;
+        }
     }
 
-    // in the case of single core increment ps_decode_cur_slice
-    if((ps_dec->u1_separate_parse == 0) && (ps_dec->u4_first_slice_in_pic == 0))
-    {
-        ps_dec->ps_decode_cur_slice++;
-    }
     ps_dec->u1_slice_header_done = 0;