Merge cherrypicks of [15164514, 15164515, 15164096, 15164078, 15163495, 15164068, 15164480, 15164097, 15164098, 15164482, 15164698, 15164375, 15164485, 15164469, 15164730, 15164731, 15164732, 15164733, 15164734, 15164735, 15164736, 15164737, 15164738, 15163662, 15164486, 15164519, 15164699, 15164700, 15164487, 15164099] into rvc-qpr3-release am: 60ba588853

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/libavc/+/15164376

Change-Id: Ic12a9acfd1cc6545504f3783c4073f5f5fa45400
diff --git a/decoder/ih264d_parse_slice.c b/decoder/ih264d_parse_slice.c
index cc1d90f..f922cfe 100644
--- a/decoder/ih264d_parse_slice.c
+++ b/decoder/ih264d_parse_slice.c
@@ -1435,17 +1435,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;