summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_ratectrl.c
AgeCommit message (Collapse)Author
2019-05-24Merge "Increase active best quality linearly"Jingning Han
2019-05-21Clamp for min_frame_targetJingning Han
Apply the minimum frame size clamp for all applicable frames. This avoids bit-rate undershooting issue as reported in BUG=b/133260125 Change-Id: I59ec028eee999ad5238602adf96465af7c4f4514
2019-05-17vp9-rtc: Increase qp thresh for overshoot detectionMarco Paniconi
For video mode (non-screen) in CBR real-time mode: increase the qp thresh to trigger setting to active_worst on scene changes. Avoid big overshoots in content with scene changes. Change-Id: I74721b07b0d7b742cbef468ece70cca7da0f89eb
2019-05-16Increase active best quality linearlyRavi Chaudhary
The ARF frames in last few gf intervals, would be used as a reference by fewer ARF frames in the same kf interval. Also, the ARF frames in the last GF group would not be used as a reference in future. Hence the active best quality for these ARF frames is increased based on their temporal distance from the next key frame. Change-Id: Ice7eaa8a25384104b1d9cc021eec588c03053fc2
2019-04-18Increase the active best quality in CQDeepa K G
For boosted frames, active best quality is increased. Change-Id: I282fbefaf16b4216f5d22d344f098e6a5766c4a5
2019-04-18Refine active best quality of layered ARF framesRavi Chaudhary
Change-Id: If630af68fc3793d579a947d5955c2001c0cf0a8d
2019-04-09vp9-rtc: Fix to active_best for non-SVCMarco Paniconi
For 1 pass CBR non-SVC encoding, on golden refresh: condition lower/boosted active_best_quality setting only if gf_cbr_boost_pct is set. Reduces overshoot for hard clips. Neutral change on rtc metrics. Change-Id: I10f7e27767a3f80d63958a7e137155f7bc20504b
2019-03-13vp9-svc: Reorganize the simulcast modeMarco Paniconi
Set the lst/gld/alt_fb_idx and refresh flags for key frames at the start of encoding (in svc_set_params). This then avoids new code/function in update_references() and in copy_flags_ref_update(). Change-Id: Id3503c0c628540c20f11a540c118c4ee4cf04848
2019-03-07vp9 svc: add simulcast mode when inter-layer pred is off.Jerome Jiang
Force all upper spatial layers to be key frame if the base layer is key. Mode only works for inter-layer pred=off and non-flexible mode. Add flag to write out bitstream for each spatial layer in example encoder. Change-Id: I5db4543cf8697544ae49464f2157e692640d5256
2019-03-01vp9-rtc: Fix for scroll motion for rtcMarco Paniconi
Increase threshold to detect frames with high num of motion blocks, and fix conditions to detect horiz & vert scroll and avoid split below 16x16 blocks in variance partition. Reduces artifacts in horizonal scroll screenshare testing. Change-Id: Icf5b87f69971d7331c660fc2727c9246c6cbf8b5
2019-02-24vp9-rtc: Fix to Q clamp in adjust_q_cbrMarco Paniconi
For CBR mode: clamp the Q to worst/best quality in adjust_q_cbr(). Under certain conditions, when the worst/best quality is suddenly changed by a large amount mid-stream, the Q adjustment from the final Q from adjust_q_cbr may not respect the worst/best qualiy limits. Change-Id: I3776129325d89882d422b22e6247d44660dd90ac
2019-02-05Fix VPX_KF_DISABLED.Jerome Jiang
VP9 encoder still inserts key frame periodically when VPX_KF_DISABLED is set in non SVC for 1-pass CBR. BUG=webm:1592 Change-Id: Ie99d7c5b95230d739e263a2d87879693c53f620e
2019-01-15vp9-svc: Fix to buffer update under frame_dropsMarco Paniconi
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
2019-01-14vp9-svc: Rate control fix for key base layerMarco Paniconi
After encoding key frame on base spatial layer, if the overshoot is significant, reset the avg_frame_qindex[INTER] on base spatial layer for all temporal layers. This forces the active_worst_quality to increase on subsequent frames/layers and reduces frame dropping. Change-Id: I53a3cd14131d69120e59a649b7ed1bfde3e940ee
2018-12-12Merge "Use undamped adjustment for rate correction factors"Deepa K G
2018-12-11Use undamped adjustment for rate correction factorsDeepa K G
Undamped adjustment is used for the first frame of each frame type while updating the rate correction factors. Change-Id: I42f80daa123c4cd4e45c18c6960cc7a67e7df7e6
2018-12-10Clean up condition logics in rc_pick_q_and_bounds_two_pass()Jingning Han
Factor out common conditions for better readability. Change-Id: I2a2b576e7d3e5cf036e9e355fc7ce0509ecb3d7e
2018-12-04Merge "Clean up rc_pick_q_and_bounds_two_pass()"Jingning Han
2018-12-03vp9-svc: Fix to postencode drop for layers.Marco Paniconi
Postencode drop is only checked on base spatial layers, and if set, whole superframe is dropped and and next superframe is encoded at max-q. Fix here is to make sure all layers are encoded at max-q on a postencode dropped frame. Change-Id: I2313d83ee29a382465bcec1085d8c73c37ce26d6
2018-12-03Merge "vp9: Rename post_encode drop function."Marco Paniconi
2018-12-03vp9: Overshoot detection for skipped base layer.Marco Paniconi
If scene/slide change is detected on current superframe and max-q set because of high overshoot: then if the lower/base spatial layer are skipped on the current superframe, max-q is forced on the next encoded base/lower spatial layers. Change-Id: Id61efda86ee545395012e19476d19845e3932678
2018-12-03vp9: Rename post_encode drop function.Marco Paniconi
Feature works also for non-screen content mode, so rename it. Change-Id: I665362d50cf9a4017f114973586ad0eead066ddd
2018-11-30Clean up rc_pick_q_and_bounds_two_pass()Jingning Han
Remove unneeded VPX_Q condition check. Change-Id: I46b09ae522caa47fa7ea4441b6a6ac2840315d1c
2018-11-30Simplify constant q mode qp selectionJingning Han
Decouple the constant q mode qp selection from vbr/cbr/cq modes. Skip vp9_frame_type_qdelta() adjustment for non-ARF inter frames, instead keep using the cq-level. It improves the compresson performance: avg PSNR overall PSNR SSIM lowres -0.17% -0.20% -0.1% midres -0.21% -0.24% -0.08% hdres -0.15% -0.19% -0.04% Change-Id: I52fd5f8edbd3fdcbeda31ee3a6d6eb016091a7e3
2018-11-29Factor key frame qp selection from two-pass qp and bound decisionJingning Han
Factor out this common code needed all rate control modes. Change-Id: If17850fbebcdce7ff24afb211aa2e6054486b814
2018-11-27Remove ineffective condition from rc_pick_q_and_boundsJingning Han
Change-Id: I67b92182ee80ec5548c5a97345b6252e49033c4a
2018-11-26Fix ARF rate allocation for cq modeJingning Han
In the limited test set, it improves the cq mode compression performance by 1.9% in PSNR and 6% in SSIM as compared to use same quantization parameter for all ARFs. Change-Id: I35c4d7097b5838ab0b92d7f9937520721e3bb84b
2018-11-20vp9-svc: Reset temporal layers on scene changeMarco Paniconi
Reuse existing function for resetting temporal layer pattern. And fix to use first spatial layer to encode, and some refactoring in encode_without_recode_loop(). Change-Id: Ifb22bb9de793ecb8e73f410e125c7c12383da1d2
2018-11-19vp9: Fix to the svc buffer updateMarco Paniconi
Condition the pre-encode buffer update based on TS diff on temporal layers = 1 for now, as some fix is needed for the case where #temporal_layers > 1. Change-Id: I58163b956db415217e4687a31f8ba110545b09f5
2018-11-16vp9: Reorganize the buffer level for cbr modeMarco Paniconi
Refactor the code with some changes. Split update into two parts: move the fillup (with per-frame-bandwidth) before the encoding, and keep the leaking part (with encoded_frame_size) after the encoding (postencode). For SVC with ref_frame_config usage: allow usage of timestamp delta for the fillup part of buffer, instead of the (average) framerate passed in via the duration. Moving the buffer fillup (+per-frame-bandwidth) part to the pre-encode causes some difference in performance (since buffer level affects active_worst/QPand frame-dropping), but the change is observed to be small. Made small adjustment to active_worst_quality to compensate. Adjust some thresholds in datarate tests. Change-Id: I81a5562367034f318cffd451304bc4a34bf02a1d
2018-11-07Merge "vp9: postencode drop frame for screen content in CBR."Jerome Jiang
2018-11-06vp9: postencode drop frame for screen content in CBR.Jerome Jiang
Encode the next frame at max q. For layers: post_encode_drop is only check on base spatial layer, and if base is post-encoded-dropped, then whole superframe is dropped. Added API to guard postencode dropping. Turned off by default. Added unittest. BUG=b/112990050 Change-Id: I42fee279014aca616f7a4d9b582cb2bf5da2f2e7
2018-11-06vp9 screen-content: Adjustments for screen content.Marco Paniconi
Increase search area, use NSTEP, and in some cases avoid bsize below 16x16. This for base spatial layer when many blocks in the frame have motion (from scene detection analysis). Improves quality for scrolling motion. Change-Id: If77b43e738a6c43610d4727a95712667088db564
2018-10-29Properly space qp in q mode for multi-layer ARFJingning Han
Space the quantization parameter distribution according to the layer depth for multi-layer ARF coding structure. This allows lower layers to have relatively smaller quantization parameters than higher layers. It improves the compression performance in constant q mode for multi-layer ARF system: avg PSNR overall PSNR SSIM lowres -0.33% -0.31% -1.44% midres -0.29% -0.38% -1.14% hdres -0.27% -0.49% -1.02% Change-Id: I9cfe2f27e6c0029c30614970a46de3045840264e
2018-10-23Reset frame udpate flags after qp estimate in tplJingning Han
After the frame quantizer estimate run in tpl model, reset the actual value assigned to the current coding frame. This would avoid certain frame update flags being overwritten by different frame types' update. Change-Id: Idde2ba1108f1f68747b14149b211f882965c99f0
2018-10-23Fix frame offset computation for GOP extensionJingning Han
Properly compute the extended GOP frames' buffer offsets. Change-Id: I9aed14f4b8d623f1832e782828dce07aa546507d
2018-10-23Refactor gop_length use case in tpl modelJingning Han
Make it support both single- and multi-layer ARF GOP structure. Change-Id: I760a95804d1b583b057120f6d6be65195a0e6c19
2018-10-17For keyframe-only coding do not boost in q modeUrvang Joshi
If we are using keyframe only coding - either coding a single frame, or a sequence of keyframes - in the end-usage=q mode, use the cq_level directly as the quality of each coded frame, rather than boost them. Ported from AV1: 563a0d1eb92bdc1e987df071a568d8406c4ffa92 Change-Id: I6dc929b8b4f0aa18e279139077f3a87958c92245
2018-09-28Merge "Add MID_OVERLAY_UPDATE frame type"Jingning Han
2018-09-27Add MID_OVERLAY_UPDATE frame typeJingning Han
Add a MID_OVERLAY_UPDATE abstract to support multi-layer ARF-Overlay frame based approach. When setting the frame update type to be USE_BUF_FRAME, the encoder will use show_existing_frame to process the intermediate ARF frames. When setting the frame update type to be MID_OVERLAY_UPDATE, the intermediate ARF frames will go through an overlay frame for display. Change-Id: Ia0c91452c09d39312ac22d855cdf681b7da851c5
2018-09-25Use layer dependent gfu_boost factorJingning Han
When multi-layer ARF is enabled, use the corresponding gfu_boost factor assigned to each ARF to compute the best_quality_index adjustment. This on average improves the coding performance by 0.2% for lowres and hdres, 0.4% for ntflx2k. It seems this change will only affect a small group of clips, e.g., pamphlet, bowing, mobcal_720p, etc., which tend to gain 4-5%, whereas the rest clips remain largely identical coding statistics. Change-Id: Ie19636a6cf32214aefd73e21ead2aea647ddbca8
2018-09-11Simplify vp9_frame_type_qdelta()Jingning Han
Make direct use of frame type in the available VP9_COMMON structure. Eliminate the need to map through rf_level to fetch the frame type. This change doesn't alter the coding stats. It simplifies the vp9_frame_type_qdelta() function logic and removes unnecessary reference to rf_level. Change-Id: I1a7b2f5abcae39aa4a60d08a6011dde38ecf3b58
2018-09-03Revert "Revert "Prevent double application of min rate in two pass.""Paul Wilkins
This rate control bug in the original patch is not the underlying cause of the quality regression but simply unmasked a problem which stems from applying 0 bits to the last frame in a short KF group at the start of a chunk. This reverts commit d10b1f233657054b1465d40f0b409c20029a540b. Change-Id: I32c91a24a14d013853bb8e5587aa69600e6a0063
2018-08-31vp9-svc: Add first_spatial_layer_to_encode per superframeMarco Paniconi
VP9E_SET_SVC_LAYER_ID sets the first spatial layer to encoder per superframe, so add this parameter to svc encoder. This is needed, for example, to properly set is_key_frame for spatial layers when base spatial layer is skipped encoded. Change-Id: Ifd4ac77f539197ec021e62f4c624a6cc79d64f43
2018-08-23Revert "Prevent double application of min rate in two pass."Hui Su
This reverts commit 416b7051d7f610ed6d62dff18af7776ec520fd9c. Reason for revert: it causes visual quality drop as described in b/112953058. Original change's description: > Prevent double application of min rate in two pass. > > The initial allocation of bits in the two pass code to each frame > should be within the min max limits on the command line. However, > when forming an ARF group the cost of the ARF is shared by frames > in that group such that the residual bits for a frame could drop below > the min value. This change prevents the minimum being re-applied > after the cost of the ARF has been deducted as this may otherwise > cause low rate sections to overshoot their target. > > Test runs comparing to a baseline run with min and max section pct > 0-2000% vs one closer to the YT use case (50-150%) suggest that > this fix not only results in better rate control but also gives a better > rd outcome. > > For example the HD set vs 0-2000% baseline (opsnr, ssim). > Old code (50-150): +0.751, +1.099 > New code(50-150): +0.241, -0.009 > > Change-Id: I715da7b130bf53ba8aa609532aa9e18b84f5e2ef TBR=yaowu@google.com,paulwilkins@google.com,debargha@google.com,builds@webmproject.org # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Ic9849e4e0db64e9d92bbb9df9cc923230a15c4df
2018-08-22Set refresh_frame_context flag off in show_existing_frame modeJingning Han
Match the decoder expectation, set off refresh_fame_context flag in show_existing_frame mode. Change-Id: I5258635b715ea04f41a4a087178709f707449b71
2018-08-21Control reference frame refresh flags for USE_BUF_FRAMEJingning Han
The enum USE_BUF_FRAME makes the use of show_existing_frame. In this setting, all the reference frame buffer condition will stay unchanged. Change-Id: I5b7b28488dbd94982f721667128f004e4e6a00d8
2018-08-13vp9: Small refactor on overshoot detection, for cbr real-time.Marco Paniconi
Change-Id: I70997d35a2371bb4614d716ef0c587fa12ea0f4a
2018-08-09vp9: Allow for overshoot detection for non-screen CBR mode.Marco Paniconi
For CBR real-time mode: refactor usage of speed feature to handle overshoot on slide/scene change. Add 2 modes to indicate how slide/scene change is processed for re-setting Q/rate control. Keep the speed setting to 1 for speed >= 5, otherwise set to 0. Video content and screen content are now handled in similar way, though with different thresholds. Some fixes to thresholds and reset: correct the reset of the buffer level to optimal level for each temporal layer, if scene change frame will be encoded at max_q. Also increase the min_thresh for video mode (non-screen content): this is to avoid scene change detection on cases like large lighting changes, cameras focus. And increase in min_thresh makes it more robust to sudden increase in noise level. Change-Id: I256d350da6e92d2ddc09f100fc06ac147cbc1e49
2018-08-09vp9-svc: Fix for scene detection for SVCMarco Paniconi
For spatial layers: use the correct mi_cols/rows in the scene detection. The scene detection for spatial layers is only called once per superframe, but we were using wrong mi_cols/rows (those for base spatial were being used). Also increase frame_since_key threshold to account for spatial layers. Change-Id: I2731da49684a798c4718693a0468eda7db82d2bd