Mitigate issues around arithmetic overflow am: a2c1f6a13f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/14251625

Change-Id: I55647bf06ae54f4162a7a507d075a8ee39454809