summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.c
diff options
context:
space:
mode:
authorpaulwilkins <paulwilkins@google.com>2015-05-07 11:55:53 +0100
committerpaulwilkins <paulwilkins@google.com>2015-05-20 16:47:34 +0100
commit883fdd45cfbb1b12ff746fbb88df88522e20b5c1 (patch)
tree3e11370462bed30a038cc1a43135c59541b33180 /vp9/encoder/vp9_firstpass.c
parentade9693a30821af5c28b947090aa6d41cb27ea20 (diff)
downloadlibvpx-883fdd45cfbb1b12ff746fbb88df88522e20b5c1.tar
libvpx-883fdd45cfbb1b12ff746fbb88df88522e20b5c1.tar.gz
libvpx-883fdd45cfbb1b12ff746fbb88df88522e20b5c1.tar.bz2
libvpx-883fdd45cfbb1b12ff746fbb88df88522e20b5c1.zip
Fast feedback of bits on undershoot.
This patch provides a partial rapid feedback of bits resulting from extreme undershoot. Some improvement on some problem animated material but in its current form only a small impact on the metrics results of our standard test sets. Change-Id: Ie03036ea8123bc2553437cb8c8c9e7a9fc5dac5d
Diffstat (limited to 'vp9/encoder/vp9_firstpass.c')
-rw-r--r--vp9/encoder/vp9_firstpass.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 40f65c3e0..2f96a7948 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1247,8 +1247,9 @@ void vp9_init_second_pass(VP9_COMP *cpi) {
twopass->modified_error_left = modified_error_total;
}
- // Reset the vbr bits off target counter
+ // Reset the vbr bits off target counters
cpi->rc.vbr_bits_off_target = 0;
+ cpi->rc.vbr_bits_off_target_fast = 0;
cpi->rc.rate_error_estimate = 0;
@@ -2650,6 +2651,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
#define MINQ_ADJ_LIMIT 48
#define MINQ_ADJ_LIMIT_CQ 20
+#define HIGH_UNDERSHOOT_RATIO 2
void vp9_twopass_postencode_update(VP9_COMP *cpi) {
TWO_PASS *const twopass = &cpi->twopass;
RATE_CONTROL *const rc = &cpi->rc;
@@ -2716,5 +2718,32 @@ void vp9_twopass_postencode_update(VP9_COMP *cpi) {
twopass->extend_minq = clamp(twopass->extend_minq, 0, minq_adj_limit);
twopass->extend_maxq = clamp(twopass->extend_maxq, 0, maxq_adj_limit);
+
+ // If there is a big and undexpected undershoot then feed the extra
+ // bits back in quickly. One situation where this may happen is if a
+ // frame is unexpectedly almost perfectly predicted by the ARF or GF
+ // but not very well predcited by the previous frame.
+ if (!frame_is_kf_gf_arf(cpi) && !cpi->rc.is_src_frame_alt_ref) {
+ int fast_extra_thresh = rc->base_frame_target / HIGH_UNDERSHOOT_RATIO;
+ if (rc->projected_frame_size < fast_extra_thresh) {
+ rc->vbr_bits_off_target_fast +=
+ fast_extra_thresh - rc->projected_frame_size;
+ rc->vbr_bits_off_target_fast =
+ MIN(rc->vbr_bits_off_target_fast, (4 * rc->avg_frame_bandwidth));
+
+ // Fast adaptation of minQ if necessary to use up the extra bits.
+ if (rc->avg_frame_bandwidth) {
+ twopass->extend_minq_fast =
+ (int)(rc->vbr_bits_off_target_fast * 8 / rc->avg_frame_bandwidth);
+ }
+ twopass->extend_minq_fast = MIN(twopass->extend_minq_fast,
+ minq_adj_limit - twopass->extend_minq);
+ } else if (rc->vbr_bits_off_target_fast) {
+ twopass->extend_minq_fast = MIN(twopass->extend_minq_fast,
+ minq_adj_limit - twopass->extend_minq);
+ } else {
+ twopass->extend_minq_fast = 0;
+ }
+ }
}
}