Merge "Decoder: Fix integer overflow in poc calculation" am: 159799b4d4

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

Change-Id: Ic170fcb5a850f2fbf09043b81b92a0b31380b7c3
diff --git a/decoder/ih264d_parse_pslice.c b/decoder/ih264d_parse_pslice.c
index 9b9256b..43979dc 100644
--- a/decoder/ih264d_parse_pslice.c
+++ b/decoder/ih264d_parse_pslice.c
@@ -1494,7 +1494,11 @@
             ps_dec->p_motion_compensate = ih264d_motion_compensate_bp;
 
             if(ps_dec->ps_cur_pic != NULL)
-                poc = ps_dec->ps_cur_pic->i4_poc + 2;
+            {
+                poc = ps_dec->ps_cur_pic->i4_poc;
+                if (poc <= INT32_MAX - 2)
+                    poc += 2;
+            }
 
             j = -1;
             for(i = 0; i < MAX_NUM_PIC_PARAMS; i++)