summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.h
AgeCommit message (Collapse)Author
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-05-18Changes to modified error.paulwilkins
The modified error was a derivative of the "coded_error" that was used to allocate bits between different frames on the assumption that the allocation should be linear in terms of this modified error. I.e. a frame with double the modified error score should all things being equal get double the number of bits. The code also included upper and lower caps derived from input VBR parameters. This patch improves the initial calculation of the clip mean error (now called "mean_mod_score" as it is no longer a prediction error) used as the midpoint for the rate distribution function and normalizes the output "modified scores" scores such that 1.0 indicates a frame in the middle of the distribution. The VBR upper and lower caps are then applied directly to a frame's normalized score. This refactoring is intended to make it easier to drop in alternative distribution functions or to base the rate allocation on a corpus wide midpoint (rather than the clip mean). Change-Id: I4fb09de637e93566bfc4e022b2e7d04660817195
2017-05-17Experiment. Store first pass errors as per MB values.paulwilkins
Most existing first pass stats are stored in a form normalized to a macro-block scale. However the error scores for intra / inter etc were stored as frame level values but mainly used as MB level values. This change fixes that. Normalized per MB values make comparisons between different formats easier and in any case this is usually what is wanted. An change in results should be limited to slight differences in rounding. *** Change after patch 8 +2 requiring new approval. Final pre-submit testing showed one 4K clip with above expected change. Investigation showed this was due to a value used to test for ultra low intra complexity in key frame detection. This was a per frame not per MB value but also did not scale with frame size. Replacement with a small per MB value (based on original per frame value and cif frame size) resolved the KF detection problem. Also converted kf_group_error_left to a double in line with other error values to reduce rounding problems in KF group bit allocation All clips and sets now show nominal (or 0) change as expected. Change-Id: Ic2d57980398c99ade2b7380e3e6ca6b32186901f
2017-02-22Merge "Refactored the row based multi-threading code"Yunqing Wang
2017-02-20Refactored the row based multi-threading codeRanjit Kumar Tulabandu
Modified the code to facilitate bit-match tests in first pass Added unit-tests to test the row based multi-threading behavior for bit-exactness Change-Id: Ieaf6a8f935bb1075597e0a3b52d9989c8546d7df
2017-02-15Additional first pass stats.paulwilkins
Added counts that split the intra coded blocks into low and high variance. Change-Id: Ic540144b34d5141659081bb22f7ee16fd6861f14
2017-01-24Multi-threading of first pass stats collectionRanjit Kumar Tulabandu
(yunqingwang) 1. Rebased the patch. Incorporated recent first pass changes. 2. Turned on the first pass unit test. Change-Id: Ia2f7ba8152d0b6dd6bf8efb9dfaf505ba7d8edee
2016-12-07Remove an unused first pass statisticYunqing Wang
One of the first pass stats "new_mv_count" is no longer used in VP9, and is removed. This also makes it easy to implement a multi-threaded first pass. This change doesn't affect the coding performance, which has been verified by borg tests. Change-Id: I4c7c7bf9465fda838eb230814ef0c631c068c903
2016-08-10Modified ARF group allocation.paulwilkins
Small average gains in the range 0.05 - 0.1 Change-Id: I30e85c04be615cc84726427c5057388b20a6ff60
2016-08-02vp9/encoder: apply clang-formatclang-format
Change-Id: I45d9fb4013f50766b24363a86365e8063e8954c2
2016-07-07Noise energy Experiment in first pass.paulwilkins
Use a measure of noise energy to adjust Q estimate and arf filter strength. Gains 0.3-0.5% on Lowres and |Netflix sets. Hdres and Midres neutral. Change-Id: Ic0de552e7b6763e70eeeaa3651619831b423e151
2016-06-03Removed unused data structure.paulwilkins
Removed unused element from TWOPASS data structure. Change-Id: I9b662fd8eea727a7978055bc14f7c7328f048a5e
2016-06-03Adjustment calculation of active worst quality.paulwilkins
Added a factor based on the bit spend in the last arf group vs the target to adjust the choice of the active worst quality in subsequent groups. Helps clips where previously there was a big overshoot or undershoot to adapt and get closer to the target rate. Change-Id: I67034b801679b99024409489a2273ea6fe23b8e6
2016-06-03Remove gf_zeromotion_pct.paulwilkins
The use of this value is preventing rate adjustment on clips or sections that have very little motion but high noise and this can give rise to some sections with massive overshoot. Change-Id: I9a65c7c1148dc5d3a7d8b23e50fc1733f3661621
2016-04-09Step towards making the 2-pass cq mode perceptualDebargha Mukherjee
Uses a metric on fraction of smooth blocks derived from first pass stats in a frame to adjust down the cq_level modestly in the cq mode. The current implementation does not add much complexity, and is fairly light in the adaptation. Change-Id: Ic484e810d5bd51b7bb6b8945f378c7c3d9d27053
2015-08-28vp9_firstpass: make vp9_init_subsampling privateJames Zern
Change-Id: I03b2ae99ec2e212c76bf815de7d5745b5c965d57
2015-07-08Change speed and rd features for formatting bars.paulwilkins
Change speed features / behavior for split mode when there is an internal active edge (e.g. formatting bars). Remove some threshold constraints in rd code near the active edge of the image. Add some plumbing for left and right active edge detection. Patch set 5. Limit rd pass through for sub 8x8 to internal active edges. This takes away any speed penalty for most clips but keeps the enhanced edge coding for the more critical case of internal image edges Change-Id: If644e4762874de4fe9cbb0a66211953fa74c13a5
2015-06-09Changes to active maxq calculation in two pass.Paul Wilkins
Some initial experiments into discounting dead zone formating bars and intra skip blocks (common in some types of animation and graphics) in the calculation of the active max Q for each ARF/GF group. TODO: check for vertical formating bars and validate the horizontal bar at the bottom edge of the image. As expected, this change as it stands, does not make much difference for the natural videos in the std-hd and derf sets. However, for the yt and yt hd set there is a significant rise in the average PSNR with overall PSNR and SSIM remaining neutral. The mean rise for the YT-HD test set was > 6%. This is mainly because the change allows Q to drop further on titles and other graphics sections where spending a small number of extra bits gives a sharp rise in PSNR. Change-Id: I3f878ae91fc1854312d7ecf9fa792c17bc1aa6b7
2015-06-09Enable more split modes for animated content.Paul Wilkins
For content that is identified as likely to contain some animation or graphics content, increase the availability of split modes for good quality speeds 1-3. On a problem test animation clip this improves metrics results by about 0.25 db and makes a noticeable difference visually. It also causes a small drop in file size (~0.5%) but a rise in encode time of about 5-6% at speed 2. For more normal content it should have no effect. Change-Id: Ic4cd9a8de065af9f9402f4477a17442aebf0e439
2015-06-04Animation and dead zone detection.Paul Wilkins
Adds code to detect dead zone bars at the top and bottom of reformatted letterbox video (note that the code only looks at the top of the image and assumes any dead zone is symmetrical). Use of this to adapt rate control etc. will follow in a subsequent patch. Also counts other blocks (excluding the dead zone) that have no intra signal. The presence of a significant number of such blocks can be used as a identify that the frame may be artificial (e.g. animation, screen capture, graphics). This patch contains plumbing only and does not use the signal. Change-Id: I59bc93529cd4065416cef773e405fda3ae006a20
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-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-26Adjust active maxq for GF groups.Paul Wilkins
Currently disabled by default: enabled using #define GROUP_ADAPTIVE_MAXQ In this patch the active max Q is adjusted for each GF group based on the vbr bit allocation and raw first pass group error. This will tend to give a lower q for easy sections and a higher value for very hard sections. As such it is expected to improve quality in some of the easier sections where quality issues have been reported. This change tends to hurt overall psnr but help average psnr. SSIM also shows a small gain. Average results for derf, yt, std-hd and yt-hd test sets were as follows (%change for average psnr, overal psnr and ssim):- derf +0.291, - 0.252, -0.021 yt +6.466, -1.436, +0.552 std-hd +0.490, +0.014, +0.380 yt-hd +5.565, - 1.573, +0.099 Change-Id: Icc015499cebbf2a45054a05e8e31f3dfb43f944a
2014-11-20Add adaptive midpoint for AQ1.Paul Wilkins
Make the midpoint variance used in AQ mode 1 segmentation depend on the overall complexity of the frame in two pass. Change-Id: I452814ec57f7a32352e41bb250e78066abe952dd
2014-11-06Add intra complexity and brightness weight to first pass.Paul Wilkins
The aim of this patch is to apply a positive weighting to frames that have a significant number of blocks that are of low spatial complexity and are dark. The rationale behind this is that artifacts tend to be more visible in such frames. In this patch the weight is only applied in regard to the distribution of bits between frames. Hence if all the frames share similar characteristics (as is the case for most of our short test clips) there will be little or no net effect. However, the effect can be seen on some longer form test content. For example Tears of steel baseline test: 2323.09 Kbit/s opsnr 39.915 ssim 74.729 With this patch:- 2213.34 Kbit/s opsnr 39.963 ssim 74.808 (Sligtly better metrics and about 5% smaller) The weighting may well need some further tuning along side changes to the aq modes. Change-Id: Ieced379bca03938166ab87b2b97f55d94948904c
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-10Merge "Add adaptation option for VBR."Paul Wilkins
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-10-08Allow mode search breakout at very low prediction errorsYunqing Wang
In model_rd_for_sb function, the spatial domain SSE and variance are checked to see if transform coefficients are quantized to 0. Besides that, this patch adds another set of thresholds that are much more strict. These thresholds are used to conduct a partition block level check to measure if all its TX blocks are skippable for YUV planes. If it is true, x->skip is set for this partition block, and thus its mode search is terminated. This speeds up the encoding at very low prediction error case, such as screen sharing application. This patch covers what rd_encode_breakout_test() does, so that function is removed. Borg test at speed 3 shows: For stdhd set, psnr: +0.008%, ssim: +0.014%; For derf set, psnr: +0.018%, ssim: +0.025%. No noticeable speed change. Change-Id: I4e5f15cf10016a282a68e35175ff854b28195944
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-08-22Removing source field from VP9_COMP.Dmitry Kovalev
Using local variables instead. Change-Id: I68737f7e392b81492ffd3ef2c2ff9afbf55fb097
2014-08-04Store first pass motion vector directionsPengchong Jin
Re-organize the one-byte structure for 16x16 first pass block. Add bits to indicate motion vector directions. Change-Id: Id10754ba343dfc712c7fed5bcc85c67fa0bbcb89
2014-07-28Store block-wise statistics obtained in the first passPengchong Jin
Change-Id: I9956db2ba2f7d28f484daaf5022d8d1ef5db473c
2014-07-17Merge "Fixed a bug of setting wrong first pass mb stats pointer"Pengchong Jin
2014-07-17Fixed a bug of setting wrong first pass mb stats pointerPengchong Jin
The bug sets the wrong pointer to the first pass mb stats if the encoder does the re-coding in the second pass. Change-Id: I8a11f45dd7dceb38de814adec24cecccae370d00
2014-07-17Merge "Changes to rd balance and multi-arf bug fix."Paul Wilkins
2014-07-16Changes to rd balance and multi-arf bug fix.Paul Wilkins
2 pass only change to calculation of rd mult based on Q. Make a small adjustment based on frame type and also replace adjustment based on iifactor with an one based on the ambient GF/ARF boost level. Also fix multi arf bug / issue. Overall these change give an slight improvement in ssim but hurt psnr a little. Change-Id: I5e1751e3ff5390a26f543d7855059e6fbcce105e
2014-07-14Rewrite functions related to first pass block statsPengchong Jin
Change-Id: I28679f88e2911b06eef5cbc83ecb62b8c69e4c53
2014-07-01Store/read 16x16 block statistics obtained from the first passPengchong Jin
Add a conditional compile flag for this feature. Also add a switch to enable the encoder to use these statistics in the second pass. Currently, the switch is turned off. Change-Id: Ia1c858c35ec90e36f19f5cffe156b97ddaa04922
2014-06-24Dual ARF changes: Buffer index selection.Paul Wilkins
Add indirection to the section of buffer indices. This is to help simplify things in the future if we have other codec features that switch indices. Limit the max GF interval for static sections to fit the gf_group structures. Change-Id: I38310daaf23fd906004c0e8ee3e99e15570f84cb
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-12Removing unused ssim_weighted_pred_err field from FIRSTPASS_STATS.Dmitry Kovalev
Change-Id: Ia8c7e3905ac21732cb6b8099eaf8df72c7e36b73
2014-06-06Revert "Removing this_frame_stats member from TWO_PASS struct."Adrian Grange
Use of stack frame variable "fps" beyond the lifetime of the function. fps is sent as a paremeter to output_stats and stored in the packet holding this encoded frame. This has scope beyond the lifetime of the calling function. This reverts commit 3f95a230c7e54104201b3f6c577dfa9251b4642a Change-Id: Icd8e14b3d7dd733590ada12e619b9dce95b6b0f5
2014-05-27Removing this_frame_stats member from TWO_PASS struct.Dmitry Kovalev
Change-Id: Id8877fad1f1e88b145e7c40c43174109b9c4f373
2014-05-23Further first pass allocation changes.Paul Wilkins
Further changes to first pass allocation for gf/arf groups. Three variables removed from TWO_PASS structure as only now used locally. Dont adjust gf_group_bits in the post encode update as this will no longer have any effect. Change-Id: Iff89b225db923fc856f5d2aedbc899f1d7d68b55
2014-05-23Re-factor bit allocation in first pass.Paul Wilkins
Restructuring to allocate the bits for each frame in a GF group at the time the group is defined. At the moment the allocation closely mirrors what we had before. Also changes the default rate adjustment method to LONG_TERM_VBR_CORRECTION. Change-Id: Ie5793c46c6b9c888cead5d8790792efd7d60b7c1
2014-05-22Cleaning up vp9_init_second_pass().Dmitry Kovalev
modified_error_total from TWO_PASS struct is not required anymore. Change-Id: I0e07cac1e6d1b6a78418116be725bcd72bfbd847
2014-05-20Merge "Cosmetic clean up."Paul Wilkins
2014-05-19Cosmetic clean up.Paul Wilkins
Use type TWO_PASS instead of "struct twopass". Change-Id: I9d92920893bd436537b2ca19e9c9d355cca56c7c