ref: 6b4b82fd7a47720d608f6349bdb2cb2b81adb6a1
parent: 0702d5ab27723162d0167006ef93010649c94895
author: Jerome Jiang <jianj@google.com>
date: Thu Jul 15 12:05:16 EDT 2021
Use round to be more accurate casting float to int Change-Id: Ifd5961917831752b176dd75d39d6b2cba6ce72fa
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -301,9 +301,9 @@
/* Work out the average size of a frame within this layer */
if (layer > 0) {
lc->avg_frame_size_for_layer =
- (int)((cpi->oxcf.target_bitrate[layer] -
- cpi->oxcf.target_bitrate[layer - 1]) *
- 1000 / (lc->framerate - prev_layer_framerate));
+ (int)round((cpi->oxcf.target_bitrate[layer] -
+ cpi->oxcf.target_bitrate[layer - 1]) *
+ 1000 / (lc->framerate - prev_layer_framerate));
}
lc->active_worst_quality = cpi->oxcf.worst_allowed_q;
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -322,8 +322,8 @@
const int prev_layer_target_bandwidth =
oxcf->layer_target_bitrate[st_idx - 1];
lc->avg_frame_size =
- (int)((lc->target_bandwidth - prev_layer_target_bandwidth) /
- (lc->framerate - prev_layer_framerate));
+ (int)round((lc->target_bandwidth - prev_layer_target_bandwidth) /
+ (lc->framerate - prev_layer_framerate));
}
}