summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDebargha Mukherjee <debargha@google.com>2016-10-27 09:55:36 -0700
committerDebargha Mukherjee <debargha@google.com>2016-10-27 11:08:44 -0700
commit1cd987d9222a27f0f2dfb3b71bc2325313865b90 (patch)
tree03ef5d3ea3f775ef0509a1affb51a2fa685e8414 /vp9
parentf53d3363ac41b9997e07f5d8faac1f734c8ddc9c (diff)
downloadlibvpx-1cd987d9222a27f0f2dfb3b71bc2325313865b90.tar
libvpx-1cd987d9222a27f0f2dfb3b71bc2325313865b90.tar.gz
libvpx-1cd987d9222a27f0f2dfb3b71bc2325313865b90.tar.bz2
libvpx-1cd987d9222a27f0f2dfb3b71bc2325313865b90.zip
Speed-up recode loop for extreme bitrate diffs
Adjusts the q adjustement step depending on how far the projected and target rates differ. Change-Id: I498d03523ca233a270512ca3972c372daa4ca2a8
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_encoder.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index 4aa24b4e4..3bd6026d4 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3216,6 +3216,13 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
vpx_clear_system_state();
}
+#define MAX_QSTEP_ADJ 4
+static int get_qstep_adj(int rate_excess, int rate_limit) {
+ int qstep =
+ rate_limit ? ((rate_excess + rate_limit / 2) / rate_limit) : INT_MAX;
+ return VPXMIN(qstep, MAX_QSTEP_ADJ);
+}
+
static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size,
uint8_t *dest) {
VP9_COMMON *const cm = &cpi->common;
@@ -3389,6 +3396,7 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size,
// to attempt to recode.
int last_q = q;
int retries = 0;
+ int qstep;
if (cpi->resize_pending == 1) {
// Change in frame size so go back around the recode loop.
@@ -3414,7 +3422,10 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size,
q_high = rc->worst_quality;
// Raise Qlow as to at least the current value
- q_low = q < q_high ? q + 1 : q_high;
+ qstep =
+ get_qstep_adj(rc->projected_frame_size, rc->this_frame_target);
+ q_low = VPXMIN(q + qstep, q_high);
+ // q_low = q < q_high ? q + 1 : q_high;
if (undershoot_seen || loop_at_this_size > 1) {
// Update rate_correction_factor unless
@@ -3439,7 +3450,10 @@ static void encode_with_recode_loop(VP9_COMP *cpi, size_t *size,
overshoot_seen = 1;
} else {
// Frame is too small
- q_high = q > q_low ? q - 1 : q_low;
+ qstep =
+ get_qstep_adj(rc->this_frame_target, rc->projected_frame_size);
+ q_high = VPXMAX(q - qstep, q_low);
+ // q_high = q > q_low ? q - 1 : q_low;
if (overshoot_seen || loop_at_this_size > 1) {
vp9_rc_update_rate_correction_factors(cpi);