From 7e2d732b8bf16579a28daa124a38ac19e1efd96c Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Tue, 15 Jan 2019 12:12:47 -0800 Subject: [PATCH] vp9-svc: Fix to buffer update under frame_drops For svc with frame dropping in full_superframe_drop or constrained dropped mode: the buffer level for a given layer may be capped from increasing too much. This is because that layer may be dropped even though its buffer is stable (the dropped is forced due to underflow in other layers in full/constrained svc-drop mode). This capping is needed to prevent decrease in qp over consecutive frame drops. The capping already exists and has been used, but this change introduce an error that prevented its usage: https://chromium-review.googlesource.com/c/webm/libvpx/+/1330875 The fix here is to also cap the bits_off_target as well, since after the change mentioned above, its the bits_off_target that is used to update buffer on next frame (which in turn affects qp for next frame/layer). Change-Id: Ifdab5d478e91cce20ecec51faa574eed375ee36b --- vp9/encoder/vp9_ratectrl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 4b9fb2754..9df2eb333 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -247,6 +247,9 @@ int vp9_rc_clamp_iframe_target_size(const VP9_COMP *const cpi, int target) { return target; } +// TODO(marpan/jianj): bits_off_target and buffer_level are used in the saame +// way for CBR mode, for the buffering updates below. Look into removing one +// of these (i.e., bits_off_target). // Update the buffer level before encoding with the per-frame-bandwidth, static void update_buffer_level_preencode(VP9_COMP *cpi) { RATE_CONTROL *const rc = &cpi->rc; @@ -1924,8 +1927,10 @@ void vp9_rc_postencode_update_drop_frame(VP9_COMP *cpi) { // increasing buffer levels/overflow for certain layers even though whole // superframe is dropped, we cap buffer level if its already stable. if (cpi->use_svc && cpi->svc.framedrop_mode != LAYER_DROP && - cpi->rc.buffer_level > cpi->rc.optimal_buffer_level) + cpi->rc.buffer_level > cpi->rc.optimal_buffer_level) { cpi->rc.buffer_level = cpi->rc.optimal_buffer_level; + cpi->rc.bits_off_target = cpi->rc.optimal_buffer_level; + } } static int calc_pframe_target_size_one_pass_vbr(const VP9_COMP *const cpi) { -- 2.40.0