summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.h
AgeCommit message (Collapse)Author
2018-11-05Refactor find_arf_order()Jingning Han
Make the maximum layer depth allowed a control parameter in GF_GROUP. No coding stats would change. Change-Id: I9d17167da322831e7013d761980e1c16375a161b
2018-10-15Record gop sizeJingning Han
Keep the frame operations needed within a group of picture. Change-Id: Iece2e855f21860c930b34a3c586f084f7c61db00
2018-10-15Add frame_gop_index to GF_GROUPJingning Han
Add frame_gop_index to track the frame offset within a group of picture. This reworks the GOP frame offset calculation and use case. The coding stats remain identical. Change-Id: I94d0957bcc327f6bbeac6e84157635663c36b953
2018-10-03Clean up vp9_firstpass.hJingning Han
Remove unused functions and macros. Change-Id: I46458a60f75637c66af0e18ad876a2634e5818bb
2018-09-28Remove deprecated arf_update_index from GF_GROUPJingning Han
As we move to unify the GOP structure layout control, the variable arf_update_idx and arf_ref_idx are deprecated. Change-Id: Iadcb9e6033d419d4b2015fe747c23be59a7da787
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-27Remove deprecated variables from GF_GROUP structureJingning Han
Change-Id: I8c02216a369be6a51af9872f3ce05045038fc481
2018-09-18Add frame_start/end to gf_groupJingning Han
Keep the start and end frame index for each group of pictures. Change-Id: I23c0d22e643218cf7486b238c2986101282d3fbe
2018-09-15cosmetics: normalize include guardsJames Zern
use the recommended format [1] of: <PROJECT>_<PATH>_<FILE>_H_ [1] https://google.github.io/styleguide/cppguide.html#The__define_Guard "All header files should have #define guards to prevent multiple inclusion. The format of the symbol name should be <PROJECT>_<PATH>_<FILE>_H_." Change-Id: I2e8ab0b32fb23c30fa43cff5fec12d043c0d2037
2018-09-12Remove deprecated first_inter_indexJingning Han
With the refactoring of logics that determines if a frame needs re-code runs to adapt to the target bit-rate, the variable first_inter_index is no longer in effect use. Hence remove it. Change-Id: I045894ad1f8b1e00fa40d5a55d762bad0d31b27d
2018-09-12Remove some deprecated FRAME_UPDATE_TYPE elements.Paul Wilkins
Removal of some frame types relating to deprecated multi-arf work. Added a dummy value for the USE_BUF_FRAME frame type in the declaration of the rd_frame_type_factor[FRAME_UPDATE_TYPES] structure. Change-Id: I7173f2fe33a53117e1bde6f9621efc1a5951240b
2018-09-05Adaptive ARF factor decisionJingning Han
Re-count the factors to decide bit boost factor for the intermediate layer ARFs. Make the gfu_boost factor assigned to each ARF adapt to its local factors. This and the recursive change 5bfe9eb together improves the multi-layer ARF compression performance: avg_psnr ovr_psnr ssim lowres -0.39% -0.54% -1.6% midres -0.98% -1.26% -2.3% hdres -0.95% -1.13% -2.3% Change-Id: I5fec3ea75cae58825787dc88dadc7e8697a041ea
2018-09-05Enable adaptive rate allocation for multi-layer ARFsJingning Han
Increase the bit allocation for the intermediate layer ARFs. The current strategy assigns higher offset to the lower layer ARFs. The needed budget is borrowed from the base layer ARF allocation. Change-Id: I16b6e9cce4dab8e73e7b097674d1a8504205026e
2018-08-31Build arf index stackJingning Han
Stack the ARF frame indexes. Use the most recent one as the ARF reference frame for frame coding. Change-Id: I88a2202fa5deb2587d861b434d27ab8de0642cf7
2018-08-21Add USE_BUF_FRAME enum to FRAME_UPDATE_TYPEJingning Han
This enum indicates the use of show existing frame, and conducts no reference frame buffer update. Change-Id: I8bf3121376640baf24b580ebea58e9ccbdd641da
2018-07-20Improved coding on slide show content.Paul Wilkins
This patch adds in detection of slide show content and allows for coding of long GF only groups up to a length of 240 frames rather than coding a large number of shorter ARF groups that gradually lower the Q. In test samples 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 average psnr is dominated by the best frames in the sequence and 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. For slides displayed for several seconds, savings of >= 20% (or commensurate quality gains) are likely. This patch allows for long GF groups in static sections before and after complex transitions (e.g. fades) with one or more normal ARF groups during the transition. However, it enforces a single "normal" length GF group after the transition before any extended group is allowed. The reason for this is that the ARF that spans the transition my not have a very high quality and hence may not be a good GF for the long static section that follows. Change-Id: I66cc404c3b85e87dae9829b49d9d631cbf04e037
2018-06-22Add extra altref option for hierarchical structureZoe Liu
This CL is to hook up the implemented hierarchical structure construction as well as its corresponding bitrate allocation functionality with the defining of a GF group. Currently the hierarchical structure is off by default. Hence this CL has no impact on coding performance. Change-Id: I9e1ddfd877559e99072c23970f7fe103b64ed9ee
2018-06-19Add hierarchical structure in GF groupZoe Liu
Change-Id: I06fc4b0ad5a45c49e10a9601a2356fbc6e93d6da
2018-06-17Add update types for hierarchical refsZoe Liu
Change-Id: I0cd91187e1efc1441086772e5683fbf72d9371cf
2018-06-12Remove duplicate vp9_twopass_postencode_update defJingning Han
Change-Id: I370f37c85a02c032a8ba266b9b9445ee38eb0756
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-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