summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaulwilkins <paulwilkins@google.com>2016-05-24 15:21:13 +0100
committerpaulwilkins <paulwilkins@google.com>2016-06-03 13:17:43 +0100
commitc7ac2f38643a31c48109cb81720b4b54b684ccfd (patch)
tree79db742b14cc5abb67785022784ed48bd03a5e16
parentcd700e1ab919ca098bf78875d3a7326d91daa34d (diff)
downloadlibvpx-c7ac2f38643a31c48109cb81720b4b54b684ccfd.tar
libvpx-c7ac2f38643a31c48109cb81720b4b54b684ccfd.tar.gz
libvpx-c7ac2f38643a31c48109cb81720b4b54b684ccfd.tar.bz2
libvpx-c7ac2f38643a31c48109cb81720b4b54b684ccfd.zip
Adjustment to VBR rate correction.
Changes to the function the redistributes bits from overshoot or undershoot throughout the rest of the clip to respond more quickly. Change-Id: I90f10900cdd82cf2ce1d8da4b6f91eb5934310da
-rw-r--r--vp9/encoder/vp9_ratectrl.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 2ed305d82..7636dcf3f 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -1889,27 +1889,28 @@ static void vbr_rate_correction(VP9_COMP *cpi, int *this_frame_target) {
RATE_CONTROL *const rc = &cpi->rc;
int64_t vbr_bits_off_target = rc->vbr_bits_off_target;
int max_delta;
- double position_factor = 1.0;
-
- // How far through the clip are we.
- // This number is used to damp the per frame rate correction.
- // Range 0 - 1.0
- if (cpi->twopass.total_stats.count) {
- position_factor = sqrt((double)cpi->common.current_video_frame /
- cpi->twopass.total_stats.count);
- }
- max_delta = (int)(position_factor *
- ((*this_frame_target * VBR_PCT_ADJUSTMENT_LIMIT) / 100));
-
- // vbr_bits_off_target > 0 means we have extra bits to spend
- if (vbr_bits_off_target > 0) {
- *this_frame_target +=
- (vbr_bits_off_target > max_delta) ? max_delta
- : (int)vbr_bits_off_target;
- } else {
- *this_frame_target -=
- (vbr_bits_off_target < -max_delta) ? max_delta
- : (int)-vbr_bits_off_target;
+ int frame_window = VPXMIN(16,
+ ((int)cpi->twopass.total_stats.count - cpi->common.current_video_frame));
+
+ // Calcluate the adjustment to rate for this frame.
+ if (frame_window > 0) {
+ max_delta = (vbr_bits_off_target > 0)
+ ? (int)(vbr_bits_off_target / frame_window)
+ : (int)(-vbr_bits_off_target / frame_window);
+
+ max_delta = VPXMIN(max_delta,
+ ((*this_frame_target * VBR_PCT_ADJUSTMENT_LIMIT) / 100));
+
+ // vbr_bits_off_target > 0 means we have extra bits to spend
+ if (vbr_bits_off_target > 0) {
+ *this_frame_target +=
+ (vbr_bits_off_target > max_delta) ? max_delta
+ : (int)vbr_bits_off_target;
+ } else {
+ *this_frame_target -=
+ (vbr_bits_off_target < -max_delta) ? max_delta
+ : (int)-vbr_bits_off_target;
+ }
}
// Fast redistribution of bits arising from massive local undershoot.