summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_ratectrl.h
AgeCommit message (Collapse)Author
2018-05-30Revert 3 slide show coding changesJames Zern
This is a combination of the following 3 reverts. The changes cause issues on certain hardware devices. We'll pull them for now to allow for further investigation. Revert "Experiment regarding playback problems on Bravia TVs." This reverts commit 624f8105f5ae7e0bc82bdc7e10a4253295134a8b. Revert "Improved slide show coding" This reverts commit f4091bc30eef0fcacb5d5bd74ab7cfbc3c8aab5f. Revert "Improved coding on slide show content." This reverts commit 2fa333c2ae1b6fcc1864de12a7ad344a16e2ac0a. BUG=b/77492144 Change-Id: Ifba937792d644a9286307262f050216408e8ecf4
2018-05-18Experiment regarding playback problems on Bravia TVs.Paul Wilkins
This patch experimentally reduces the maximum GF interval for static content such as slide shows. It does not fully revert the previous slide show patches as this still allows the codec to code static sections only using GFs groups rather than ARF groups or a mix of ARF and GF groups. However, the maximum group length is reduced. Change-Id: Ia968b608efb9a67d2402b12e979695d58ddc1ad7
2018-02-09Improved coding on slide show content.paulwilkins
This patch adds in detection of slide show key frame groups. The detection assumes extremely low or 0 motion for all frames in the key frame group. If this case is detected the boost level is set to a very high value and the min Q to a lower value for the key frame itself. Alt refs and golden frames are disabled to save bits (up to a limiting maximum interval currently set to 240 frames). In test samples that I created, this patch gave rise to a substantial improvement in overall psnr and a drop in data rate. In some cases the average psnr fell, however, with the boost and minQ values set as they are. This is to be expected because previously a relatively poor key frame could be followed by progressively better alt refs. For example a key frame at q7.5 but subsequent alt refs improving it to lossless. Given that average psnr tends to be dominated by the best frames, a ramp like this from q7.5 to lossless may give a better average psnr than, for example, coding the entire sequence at q2.5. Overall psnr, however, will be much better in the latter case. The option exists to boost the key frame further which would insure much better results for all metrics, but at the expense of smaller bitrate savings. Given that these samples tend to have very good quality anyway this seems like a bad trade off. For slides displayed for several seconds, bitrate savings of >= 20% are likely and much larger gains are possible in some cases. Change-Id: Ib4b61e153c55d3f2f561153da13fdb56f397a52b
2017-12-13vp9: Reset rc flags on some configuration changes.Marco
For large dynamic changes in target avg_frame_bandwidth, or a change in resolution, via the update in change_config()), reset the under/overshoot flags (rc_1_frame, rc_2_frame) to prevent constraining the QP for the first few frames following the change. For SVC use the spatial stream avg_frame_bandwidth in reset condition. For the avg_frame_bandwidth condition, use fairly large threshold (~50%) for now in reset. This allows for better/faster QP response if, for example, application dynamically changes bitrate by large amount. Change-Id: Ib6e3761732d956949d79c9247e50dba744a535c0
2017-11-08CVBR command line option.paulwilkins
Added command line control of Corpus VBR. The new corpus vbr mode is a variant of standard VBR (end-usage=0) where the complexity distribution mid point is passed in rather than calculated for a specific clip or chunk. The new variant is enabled by setting a new command line parameter --corpus-complexity to a zero value. Omitting this parameter or setting it to 0 will cause the codec to use standard vbr mode. The correct value for a given corpus needs to be derived experimentally using a training set such that the average rate for the corpus is close to the target value. For example our using our low res test set with upper and lower vbr limits of 50%-150% and a corpus complexity value of 650 gives a similar average data rate across the set to using standard vbr. However, with the corpus mode easier clips will be allocated fewer bits and harder clips more bits rather than having the same rate target for all. Change-Id: I03f0fc8c6fb0ee32dc03720fea6a3f1949118589
2017-10-11Prevent double application of min rate in two pass.paulwilkins
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
2017-10-10Corpus Wide VBR test implementation.paulwilkins
This patch makes further changes to support an experimental corpus wide VBR mode that uses a corpus complexity number as the midpoint of the distribution used to allocate bits within a clip, rather than some average error score derived from the clip itself. At the moment the midpoint number is hard wired for testing and the mode is enabled or disabled through a #ifdef. Ultimately this would need to be controlled by command line parameters. Change-Id: I9383b76ac9fc646eb35a5d2c5b7d8bc645bfa873
2017-10-02ARF in 1 pass vbr: modify skip ref_frame in nonrd_pickmode.Marco
Speedup of ~2-3% on 1080p clips speed 6. Neutral/negligible loss in metrics on ytlive. Change-Id: I7ac47a4d8b58c566920bae29a94a0e8d59c36dee
2017-09-28vp9: Modification to adapt the ARF usage for 1 pass vbrMarco
Add stats for past ARF usage, and use it to disable ARF usage based on some conditions. Overall improvement on ytlive set, reduces the regression on the problem clips for this feature. Only affects when sf->use_altref_onepass is enabled (currently off by default). Change-Id: I66267f227ea132dc86acb730e9882f85bead2cdb
2017-06-23vp9: Use scene detection for CBR mode.Marco
Use the scene detection for CBR mode, and use it to reset the rate control if large source sad is detected and rate correctioni fact/QP is at minimum state. Avoids large frame sizes after big content change following low content period. Only affects CBR mode for 1 pass at speeds 5, 6, 7. Change-Id: I56dd853478cd5849b32db776e9221e258998d874
2017-03-27vp9: 1 pass: Move source sad computation into encodeframe loop.Marco
Refactor to split the 1 passs source sad computation into scene detection (currently used for VBR and screen-content mode), and superblock based source sad computation (used in non-rd CBR mode). This allows the source sad computation for CBR mode to be multi-threaded. No change in compression. Change-Id: I112f2918613ccbd37c1771d852606d3af18c1388
2017-02-16cosmetics: Fix spelling mistake in compile flag name.paulwilkins
agressive -> aggressive after: ce7b38459 Aggressive VBR method. Change-Id: Ie0f30b1bbc77ed9f32bec047b4a9b3d0cf4853f5
2017-02-15Merge "Aggressive VBR method."Paul Wilkins
2017-02-13Aggressive VBR method.paulwilkins
VBR method that allows a wider Q range for the first normal frame in each ARF group and then centers the min - max range for the rest of the arf group on the chosen Q value for that first frame. This allows for quite rapid adjustment of the active Q range even if the initial estimate is poor. In some cases where the ARF frames themselves are tending to undershoot but the normal frames are overshooting this can still give net undershoot. This can be corrected by allowing a larger Q delta for arf frames but is usually is a sign that the allocation to the arfs was to high. Change-Id: Icec87758925d8f7aeb2dca29aac0ff9496237469
2017-02-09Merge "Fix to avoid abrupt relaxation of max qindex in recode path"Paul Wilkins
2017-01-16Fix to avoid abrupt relaxation of max qindex in recode pathRanjit Kumar Tulabandu
The fix relaxes the max qindex based on the data from previous loop of coding if output frame size is greater than maximum frame size allowed Change-Id: Iac1f63ec67559d68766e090a7cbb80b812b2560f
2016-10-111 pass vbr: Allow for lookahead alt-ref in real-time mode.Marco
For 1 pass vbr real-time mode: Allow for the usage of alt-ref frame when non-zero lag-in-frames is used. Use non-filtered alt-ref, and select usage based on fast scene/content analysis/detection within the lag of frames. Positive gains on ytlive set: overall avgPSNR ~3-4%. Several clips are up between 5-14%, a few clips are neutral/small change. Current speed decrease is about ~5-10%. Use the flag USE_ALTREF_FOR_ONE_PASS to enable this feature (off by default for now). Change-Id: I802d2bf3d44f9cf01f6d15c76be9c90192314769
2016-08-02vp9/encoder: apply clang-formatclang-format
Change-Id: I45d9fb4013f50766b24363a86365e8063e8954c2
2016-07-18vp9: Allow usage of lookahead for real-time, 1 pass vbr.Marco
Allow usage of lookahead for VBR in real-time mode, for 1 pass vbr. Current usage is for fast checking of future scene cuts/changes, and adjusting rate control (gf interval and active_worst/target size). Added unittests (datarate) for 1 pass vbr mode, with non-zero lag. Added an experimental option to limit QP based on lookahead. Overall positive gain in metrics on ytlive set: avgPNSR/SSIM up on average ~1-3%; several clips up by 5, 7%. Change-Id: I960d57dfc89de121c4824b9a9bf88d2814e74b56
2016-07-07vp9: Adjustment of gfu_boost and af_ratio for 1 pass vbr.Marco
Modify the gfu_boost and af_ratio setting based on the average frame motion level. Change only affects 1 pass vbr. Metrics overall positive on ytlive set. On average up by ~1%, several clips up by 2-4%. Change-Id: Ic18c49eb2df74cb4986b63cdb11be36d86ab5e8d
2016-06-07vp9: Replace the avg_size_inter metric, for 1 pass vbr.Marco
Code cleaup, use existing rolling_actual/target metrics instead, set threshold to get same/similar effect. Little/no change in metrics on ytlive set. Change-Id: I74f3c3d0a143a9cf20dc9c3dee54c0f7e6a97a51
2016-05-13vp9: Update to rc-metric for keeping track of average frame size.Marco
Rename and change to how its updated. Only affects 1 pass vbr. Small change in metrics (< ~0.1%) on ytlive set. Change-Id: Ibb1fe485699b6c4a8194951c8f229abe2f64b9a5
2016-04-25vp9: Add rc quantity to track amount of low motion in scene.Marco
Use it for now in noise estimation to bypass estimation if motion level is high. Change-Id: I033662dc909f2060e4e81abf562a7ad262dc8170
2016-04-19vp9: Adjust gf period for high average Q and overshoot.Marco
For 1 pass vbr mode. Increase the gf interval for case where average Q is close to max and high overshoot is detected. Small increase in overall avg_psnr/sssim metrics (~0.2/0.1%) for ytlive, but improves the low-end (low bitrate) for several clips (less overshoot). Change-Id: Ifba40f25b4861b2e0d9832c82d5359a6a3dce9f2
2016-04-13vp9: Adjustment to scene-cut detection.Marco
Change recursive weight for average_source_sad and put some constraint on spacing between detected scene-cuts. Change only affects 1 pass real-time mode. Change-Id: I1917e748d845e244812d11aec2a9d755372ec182
2015-12-15Fixed interval, fixed Q 1 pass test patch.paulwilkins
For testing implemented a fixed pattern and delta, 1 pass, fixed Q, low delay mode. This has not in any way been tuned or optimized. Change-Id: Idf5ee179b277fa15d07a97f14f2ce5bbaae80a04
2015-10-02Turn on two-steps scaling in VP9 encoder dynamic resizing.JackyChen
First do a 3/4 scaling and then go down to 1/2 when necessary. Change-Id: I5689c5228ca7e1606baea7f960eb24d0dab04d4d
2015-10-01Two-steps scaling in VP9 encoder dynamic resizing.jackychen
Dynamic resizing now support two-steps scaling: first go down to 3/4 and then 1/2. This feature is under a flag which controls the switch between two-steps scaling and one-step scaling (1/2 only). Change-Id: I3a6c1d3d5668cf8e016a0a02aeca737565604a0f
2015-08-18Allow for re-encoding frame if high overshoot.Marco
For 1 pass CBR mode under screen content mode: if pre-analysis (source temporal-sad) indicates significant change in content, then check the projected frame size after encode_frame(), and if size is above threshold, force re-encode of that frame at max QP. Change-Id: I91e66d9f3167aff2ffcc6f16f47f19f1c21dc688
2015-07-06Expose params min-gf-interval/max-gf-intervalDebargha Mukherjee
Adds two new vp9 parameters --min-gf-interval and --max-gf-interval to enable testing based on frequency of alt-ref frames. Also adds a unit-test to test enforcement of min-gf-interval. For both these parameters the default value is 0, which indicates they are picked by the encoder, based on resolution and framerate considerations. If they are greater than zero, the specified parameter is honored. (Additional note by paulwilkins) Note that there is a slight oddity in that key frames are also GFs and considered part of GF only group. However they are treated as not being part of an arf group because for arf groups the previous GF is assumed to be the terminal or overlay frame for the previous group. (end note) Change-Id: Ibf0c30b72074b3f71918ab278ccccc02a95a70a0
2015-06-18Add dynamic resize logic for 1 pass CBR.Marco
Decision to scale down/up is based on buffer state and average QP over previous time window. Limit the total amount of down-scaling to be at most one scale down for now. Reset certain quantities after resize (buffer level, cyclic refresh, rate correction factor). Feature is enable via the setting rc_resize_allowed = 1. Change-Id: I9b1a53024e1e1e953fb8a1e1f75d21d160280dc7
2015-05-20Fast feedback of bits on undershoot.paulwilkins
This patch provides a partial rapid feedback of bits resulting from extreme undershoot. Some improvement on some problem animated material but in its current form only a small impact on the metrics results of our standard test sets. Change-Id: Ie03036ea8123bc2553437cb8c8c9e7a9fc5dac5d
2015-05-15vp9: correct some function signaturesJames Zern
silences missing prototype warnings Change-Id: Idaf68d83d2cb03847f3ee002c4d00c2ac79da604
2015-05-01Adjust ARF min and max interval.paulwilkins
Previously limit on max interval set to 0.5 seconds. Though this helped some low frame rate material it appears to be a bit too aggressive for some 24 and 25 fps content. This patch relaxes the limit to 0.75 seconds. The patch also adds a new minimum interval variable to replace the current hard wired value. This allows us to impose a limit on the maximum number of primary arfs per second for high frame rate (e.g. 50 & 60fps) content. This is to address concerns regarding playback performance on some platforms if there is a high base frame rate and very frequent arfs. Change-Id: I373e8b6b2a8ef522eced6c6d2cceb234ff763fcf
2015-02-10Auto-adaptive encoder frame resizing logicAdrian Grange
Note: This feature is still in development. Add an option for the encoder to decide the resolution at which to encode each frame. Each KF/GF/ARF goup is tested to see if it would be better encoded at a lower resolution. At present, each KF/GF/ARF is coded first at full-size and if the coded size exceeds a threshold (twice target data rate) at the maximum active Q then the entire group is encoded at lower resolution. This feature is enabled in vpxenc by setting: --resize-allowed=1 In addition, if the vpxenc command line also specifies valid frame dimensions using: --resize-width=XXXX & --resize_height=YYYY then *all* frames will be encoded at this resolution. Change-Id: I13f341e0a82512f9e84e144e0f3b5aed8a65402b
2015-01-28Change to update of rate control factors.Paul Wilkins
Remove damping parameter and use the damping formula introduced by Yaowu Xu in all cases. Change-Id: I18db7e0d0f262d5140102f259ab07821d374d285
2015-01-21Bug when last group before forced key frame is short.Paul Wilkins
Just before a forced key frame we often get a foreshortened arf/gf group. In such a case, we do not want to update rc->last_boosted_qindex, which is used to define the Q range for the forced key frame itself. This gives a small average metrics gain for the YT and YT-HD sets (eg. YT SSIM +0.141%). Change-Id: Ie06698bc4f249e87183b8f8fb27ff8f3fde216d9
2014-12-01Cyclic refresh: factor segment delta-q into rate control.Marco Paniconi
Incorporate segment delta-q into estimated bits. This generally improves the rate control under cyclic refresh (aq=3) mode. Change-Id: I1dc60fb230e7d08357fae18909d8ed27bf58e037
2014-11-18Prevent severe rate control errors in CBR modeYaowu Xu
In rare cases, the interaction between rate correction factor and Q choices may cause severe oscillating frame sizes that are way off target bandwidth. This commit adds tracking of rate control results for last two frames, and use the information to prevent oscillating Q choices. Change-Id: I9a6d125a15652b9bcac0e1fec6d7a1aedc4ed97e
2014-11-13Prepare for dynamic frame resizing in the recode loopAdrian Grange
Prepare for the introduction of frame-size change logic into the recode loop. Separated the speed dependent features into separate static and dynamic parts, the latter being those features that are dependent on the frame size. Change-Id: Ia693e28c5cf069a1a7bf12e49ecf83e440e1d313
2014-10-13Add adaptation option for VBR.Paul Wilkins
Allow min and maxQ to creep when the undershoot or overshoot exceeds thresholds controlled by the command line under_shoot_pct and over_shoot_pct values. Default is 100%,100% which ~disables adaptation. Derf results for example undershoot% / overshoot%:- Head:- Mean abs (%rate error) = 14.4% This check in:- 25%/25% - Mean abs (%rate error) = 6.7% PSNR hit -1% SSIM -0.1% 5% / 5% - Mean abs (%rate error) = 2.2% PSNR hit -3.3% SSIM - 1.1% Most of the remaining error and most of the quality hit is at extreme data rates. The adaptation code still has an exception for material that is in effect static so that we don't over adjust and over spend on YT slide show type content. (Rebase of If25a2449a415449c150acff23df713e9598d64c9 to resolve a auto-merge error) Change-Id: Iec4e1613ef0d067454751d8220edb7058dfbd816
2014-10-10Revert "Add adaptation option for VBR."Alex Converse
This reverts commit 869d4ca51957614dcf5093ebb9e322cc8a8405ca. This breaks the build via conflict with e18edd5eb651f9b7563cbd829744807402bfe0d8. Change-Id: If544b99e367a449452834eb8cce600f58c34ec0d
2014-10-10Add adaptation option for VBR.Paul Wilkins
Allow min and maxQ to creep when the undershoot or overshoot exceeds thresholds controlled by the command line under_shoot_pct and over_shoot_pct values. Default is 100%,100% which ~disables adaptation. Derf results for example undershoot% / overshoot%:- Head:- Mean abs (%rate error) = 14.4% This check in:- 25%/25% - Mean abs (%rate error) = 6.7% PSNR hit -1% SSIM -0.1% 5% / 5% - Mean abs (%rate error) = 2.2% PSNR hit -3.3% SSIM - 1.1% Most of the remaining error and most of the quality hit is at extreme data rates. The adaptation code still has an exception for material that is in effect static so that we don't over adjust and over spend on YT slide show type content. Change-Id: If25a2449a415449c150acff23df713e9598d64c9
2014-09-18Substantial reworking of code for arf and kf groups.Paul Wilkins
Substantial restructuring of the way we estimate the rate of decay in prediction quality and determine the arf interval and amount of boost used. Also other changes to support moving to a lower first pass Q which exposes some new features and allows us to better distinguish genuinely static blocks from low motion or noisy blocks. Net gains now visible on all the test sets with std-hd PSNR up 1.87%. There are still some bad outlier cases but most of these are low motion or slide show type content where the metrics are already high at any given rate. The best + case is up by more than 10%. Change-Id: I18e25170053bdf3188f493ff8062f48a74515815
2014-09-16Adds high bitdepth quantization functionsDeb Mukherjee
Adds various high bitdepth quantization functions. Change-Id: I36fc0bf75a1bd15128ed271df8723de0ac134b0c
2014-07-14[spatial svc]Implement alt reference framesMinghai Shang
All changes are for spatial svc only. 1. Enable encoding hidden frames in each layer and use alt reference idex to reference the hidden frame in each layer 2. Use golden reference idx for spatial reference 3. For those layers that don't have hidden frames (caused by lack of frame buffers), reference a hidden frame in lower layers 4. Add "auto-alt-refs" in svc options Change-Id: Idf27d1fd2fb5f3ffd9e86d2119235e3dad36c178
2014-06-24Experiment for mid group second arf.Paul Wilkins
This patch implements a mechanism for inserting a second arf at the mid position of arf groups. It is currently disabled by default using the flag multi_arf_enabled. Results are currently down somewhat in initial testing if multi-arf is enabled. Most of the loss is attributable to the fact that code to preserve the previous golden frame (in the arf buffer) in cases where we are coding an overlay frame, is currently disabled in the multi-arf case. Change-Id: I1d777318ca09f147db2e8c86d7315fe86168c865
2014-06-03Using 2 instead of 3 elements for avg_frame_qindex array.Dmitry Kovalev
The third array element was unused. 2 elements now: key- and interframe. Change-Id: I5b8b9f5d889cc96a204cedfc432059293256298e
2014-06-03Adding buffer levels to RATE_CONTROL struct.Dmitry Kovalev
Change-Id: Ib35ff854378764dc3c6745844c67a33dee545663
2014-05-30Merge "Re-factor some duplicate code."Paul Wilkins