aboutsummaryrefslogtreecommitdiff
path: root/libvpx/vp8/encoder/onyx_if.c
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2021-05-08 18:09:10 -0700
committerJames Zern <jzern@google.com>2021-05-08 18:09:59 -0700
commit6591f9ea6cc566d24b41baef0b3228493bfb853b (patch)
tree2ca8a2d4cbb553739acb3db11dec36463f8086d9 /libvpx/vp8/encoder/onyx_if.c
parentb3c4be4d4a69300b6cdd9cba0e8223b852c0dd77 (diff)
downloadlibvpx-6591f9ea6cc566d24b41baef0b3228493bfb853b.tar.gz
backport vp8/9 unsigned int overflow fix
baefbe85d Cap target bitrate to raw rate internally Bug: b/183079467 Bug: b/185431755 Test: sargo builds Change-Id: I5afad939c2e62a74f8aedbf129a49195784ed151
Diffstat (limited to 'libvpx/vp8/encoder/onyx_if.c')
-rw-r--r--libvpx/vp8/encoder/onyx_if.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libvpx/vp8/encoder/onyx_if.c b/libvpx/vp8/encoder/onyx_if.c
index dccc6ebb1..aeed719d1 100644
--- a/libvpx/vp8/encoder/onyx_if.c
+++ b/libvpx/vp8/encoder/onyx_if.c
@@ -1430,6 +1430,7 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) {
VP8_COMMON *cm = &cpi->common;
int last_w, last_h;
unsigned int prev_number_of_layers;
+ unsigned int raw_target_rate;
if (!cpi) return;
@@ -1570,6 +1571,10 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) {
cpi->oxcf.maximum_buffer_size_in_ms = 240000;
}
+ raw_target_rate = (unsigned int)((int64_t)cpi->oxcf.Width * cpi->oxcf.Height *
+ 8 * 3 * cpi->framerate / 1000);
+ if (cpi->oxcf.target_bandwidth > raw_target_rate)
+ cpi->oxcf.target_bandwidth = raw_target_rate;
/* Convert target bandwidth from Kbit/s to Bit/s */
cpi->oxcf.target_bandwidth *= 1000;
@@ -3615,7 +3620,7 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, size_t *size,
if (cpi->this_key_frame_forced) {
if (cpi->active_best_quality > cpi->avg_frame_qindex * 7 / 8) {
cpi->active_best_quality = cpi->avg_frame_qindex * 7 / 8;
- } else if (cpi->active_best_quality<cpi->avg_frame_qindex>> 2) {
+ } else if (cpi->active_best_quality < (cpi->avg_frame_qindex >> 2)) {
cpi->active_best_quality = cpi->avg_frame_qindex >> 2;
}
}