avoid 32-bit integer overflow

change calculation to scale encoder delay and padding when sample rate
changes to use 64-bit math and avoid possible 32-bit overflow.

Bug: 67737022
Test: re-ran affected use case
Change-Id: I6e37341256f3f0e3274ffdd3bad284eaacac25ab
(cherry picked from commit 73e95a9bd43724058651cb11c58dbe3fae651d56)
(cherry picked from commit e0d1b3816e73629029f552da5df31ef31bde2c19)
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index c44e868..a2eb9a8 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -5298,8 +5298,9 @@
         CHECK(mOutputFormat->findInt32("channel-count", &channelCount));
         CHECK(mOutputFormat->findInt32("sample-rate", &sampleRate));
         if (mSampleRate != 0 && sampleRate != 0) {
-            mEncoderDelay = mEncoderDelay * sampleRate / mSampleRate;
-            mEncoderPadding = mEncoderPadding * sampleRate / mSampleRate;
+            // avoiding 32-bit overflows in intermediate values
+            mEncoderDelay = (int32_t)((((int64_t)mEncoderDelay) * sampleRate) / mSampleRate);
+            mEncoderPadding = (int32_t)((((int64_t)mEncoderPadding) * sampleRate) / mSampleRate);
             mSampleRate = sampleRate;
         }
         if (mSkipCutBuffer != NULL) {