aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-01 00:15:55 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-09-01 00:15:55 +0000
commit15d9d7fad360ebe3a9c600a0352da8be7d849833 (patch)
tree2bb892d71caf976167223d81e692319771f72860
parent301f92fea3b78064662de08d22df9d0f2d0c6261 (diff)
parentde325903817061f3a390928a79136afe66dc3594 (diff)
downloadlibvpx-15d9d7fad360ebe3a9c600a0352da8be7d849833.tar.gz
Snap for 7692221 from de325903817061f3a390928a79136afe66dc3594 to mainline-art-releaseandroid-mainline-12.0.0_r5android-mainline-12.0.0_r22
Change-Id: I767a21715e952fd037f158d27704e320673520a2
-rw-r--r--README.version1
-rw-r--r--libvpx/vp8/encoder/ratectrl.c8
2 files changed, 7 insertions, 2 deletions
diff --git a/README.version b/README.version
index 7e8c25da3..f555bcc48 100644
--- a/README.version
+++ b/README.version
@@ -11,3 +11,4 @@ Local Modifications:
5e065cf9d vp8/{ratectrl,onyx_if}: fix some signed integer overflows
5eab093a7 vp9_ratectrl: fix some signed integer overflows
baefbe85d Cap target bitrate to raw rate internally
+ 5f345a924 Avoid overflow in calc_iframe_target_size
diff --git a/libvpx/vp8/encoder/ratectrl.c b/libvpx/vp8/encoder/ratectrl.c
index d8d55fce2..d93fb59a4 100644
--- a/libvpx/vp8/encoder/ratectrl.c
+++ b/libvpx/vp8/encoder/ratectrl.c
@@ -349,8 +349,12 @@ static void calc_iframe_target_size(VP8_COMP *cpi) {
}
if (cpi->oxcf.rc_max_intra_bitrate_pct) {
- unsigned int max_rate =
- cpi->per_frame_bandwidth * cpi->oxcf.rc_max_intra_bitrate_pct / 100;
+ unsigned int max_rate;
+ // This product may overflow unsigned int
+ uint64_t product = cpi->per_frame_bandwidth;
+ product *= cpi->oxcf.rc_max_intra_bitrate_pct;
+ product /= 100;
+ max_rate = (unsigned int)VPXMIN(INT_MAX, product);
if (target > max_rate) target = max_rate;
}