ref: 6581817991801224d5016c86115daf79e74bad85
parent: 91a9935717a1dc74b89f68fa272eb0542b7710d7
author: Marco Paniconi <marpan@google.com>
date: Tue Feb 5 05:54:28 EST 2019
vp8: Limit Q change for screen content CBR mode Add last_q[] to layer context, and add limit on Q change from previous layer/frame. For now put hard limit of 12 for decrease. For 1 pass CBR sreen content mode. Change-Id: Ifb972c9b6831440c80b1cb07a054c577ece930ec
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -218,6 +218,8 @@
lc->frames_since_last_drop_overshoot = cpi->frames_since_last_drop_overshoot;
lc->force_maxqp = cpi->force_maxqp;
lc->last_frame_percent_intra = cpi->last_frame_percent_intra;
+ lc->last_q[0] = cpi->last_q[0];
+ lc->last_q[1] = cpi->last_q[1];
memcpy(lc->count_mb_ref_frame_usage, cpi->mb.count_mb_ref_frame_usage,
sizeof(cpi->mb.count_mb_ref_frame_usage));
@@ -255,6 +257,8 @@
cpi->frames_since_last_drop_overshoot = lc->frames_since_last_drop_overshoot;
cpi->force_maxqp = lc->force_maxqp;
cpi->last_frame_percent_intra = lc->last_frame_percent_intra;
+ cpi->last_q[0] = lc->last_q[0];
+ cpi->last_q[1] = lc->last_q[1];
memcpy(cpi->mb.count_mb_ref_frame_usage, lc->count_mb_ref_frame_usage,
sizeof(cpi->mb.count_mb_ref_frame_usage));
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -257,6 +257,7 @@
int count_mb_ref_frame_usage[MAX_REF_FRAMES];
+ int last_q[2];
} LAYER_CONTEXT;
typedef struct VP8_COMP {
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -1125,6 +1125,14 @@
}
}
+static int limit_q_cbr_inter(int last_q, int current_q) {
+ int limit_down = 12;
+ if (last_q - current_q > limit_down)
+ return (last_q - limit_down);
+ else
+ return current_q;
+}
+
int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame) {
int Q = cpi->active_worst_quality;
@@ -1263,6 +1271,12 @@
}
}
}
+
+ // Limit decrease in Q for 1 pass CBR screen content mode.
+ if (cpi->common.frame_type != KEY_FRAME && cpi->pass == 0 &&
+ cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER &&
+ cpi->oxcf.screen_content_mode)
+ Q = limit_q_cbr_inter(cpi->last_q[1], Q);
return Q;
}