From 82a98180e43eaf85da60ad76bbdc90161d8b3500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Wed, 24 Aug 2016 12:57:31 +0900 Subject: [PATCH] Clip LCU lambda to reduce quality fluctuation Limits lambdas for each LCU based on the computed lambda from the previous frame and the frame-level lambda. --- src/rate_control.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rate_control.c b/src/rate_control.c index a631e52a..76c435a3 100644 --- a/src/rate_control.c +++ b/src/rate_control.c @@ -252,6 +252,19 @@ void kvz_set_lcu_lambda_and_qp(encoder_state_t * const state, const double target_bpp = target_bits / pixels; double lambda = clip_lambda(lcu->rc_alpha * pow(target_bpp, lcu->rc_beta)); + // Clip lambda according to the equations 24 and 26 in + // https://doi.org/10.1109/TIP.2014.2336550 + if (state->frame->num > ctrl->owf) { + const double bpp = lcu->bits / (double)pixels; + const double lambda_comp = clip_lambda(lcu->rc_alpha * pow(bpp, lcu->rc_beta)); + lambda = CLIP(lambda_comp * 0.7937005259840998, + lambda_comp * 1.2599210498948732, + lambda); + } + lambda = CLIP(state->frame->lambda * 0.6299605249474366, + state->frame->lambda * 1.5874010519681994, + lambda); + lambda = clip_lambda(lambda); lcu->lambda = lambda; state->lambda = lambda;