diff options
author | Paul Wilkins <paulwilkins@google.com> | 2015-10-26 19:12:08 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-10-26 19:12:08 +0000 |
commit | 26abc15e04527e7902f3b43ba3513be5401a4f8a (patch) | |
tree | c943d2a765e98730ed732af04ee0549c73722d21 | |
parent | 65dd056e413bbc42b99e9930d4914e22a0ec23cb (diff) | |
parent | 762c0f22648db04c8722b0425e82ad95cc2034e2 (diff) | |
download | libvpx-26abc15e04527e7902f3b43ba3513be5401a4f8a.tar.gz |
Merge "Bug in clamping of base_frame_target."
-rw-r--r-- | vp9/encoder/vp9_firstpass.c | 12 | ||||
-rw-r--r-- | vp9/encoder/vp9_ratectrl.c | 5 |
2 files changed, 10 insertions, 7 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index a6b5ebb01..e81c569bf 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -1183,10 +1183,13 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi, double group_weight_factor) { const RATE_CONTROL *const rc = &cpi->rc; const VP9EncoderConfig *const oxcf = &cpi->oxcf; + // Clamp the target rate to VBR min / max limts. + const int target_rate = + vp9_rc_clamp_pframe_target_size(cpi, section_target_bandwidth); inactive_zone = fclamp(inactive_zone, 0.0, 1.0); - if (section_target_bandwidth <= 0) { + if (target_rate <= 0) { return rc->worst_quality; // Highest value allowed } else { const int num_mbs = (cpi->oxcf.resize_mode != RESIZE_NONE) @@ -1195,7 +1198,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi, const double av_err_per_mb = section_err / active_mbs; const double speed_term = 1.0 + 0.04 * oxcf->speed; const double ediv_size_correction = (double)num_mbs / EDIV_SIZE_FACTOR; - const int target_norm_bits_per_mb = ((uint64_t)section_target_bandwidth << + const int target_norm_bits_per_mb = ((uint64_t)target_rate << BPER_MB_NORMBITS) / active_mbs; int q; @@ -2737,11 +2740,6 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { } target_rate = gf_group->bit_allocation[gf_group->index]; - if (cpi->common.frame_type == KEY_FRAME) - target_rate = vp9_rc_clamp_iframe_target_size(cpi, target_rate); - else - target_rate = vp9_rc_clamp_pframe_target_size(cpi, target_rate); - rc->base_frame_target = target_rate; { diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 1d13199f2..d70068570 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -1816,6 +1816,11 @@ void vp9_set_target_rate(VP9_COMP *cpi) { RATE_CONTROL *const rc = &cpi->rc; int target_rate = rc->base_frame_target; + if (cpi->common.frame_type == KEY_FRAME) + target_rate = vp9_rc_clamp_iframe_target_size(cpi, target_rate); + else + target_rate = vp9_rc_clamp_pframe_target_size(cpi, target_rate); + // Correction to rate target based on prior over or under shoot. if (cpi->oxcf.rc_mode == VPX_VBR || cpi->oxcf.rc_mode == VPX_CQ) vbr_rate_correction(cpi, &target_rate); |