summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_firstpass.c
AgeCommit message (Collapse)Author
2015-10-26Merge "Incorrect frame used in KF boost loop."Paul Wilkins
2015-10-23Bug in clamping of base_frame_target.Paul Wilkins
Bug relating to issue:- http://b/25090786 base_frame_target is supposed to track the idealized bit allocation based on error score and not the actual bits allocated to each frame. The clamping of this value based on the VBR min and max pct values was causing a bug where in some cases the loop that adjusts the active max quantizer for each GF group was running out of bits at the end of a KF group. This caused a spike in Q and some ugly artifacts. A second change makes sure that the calculation of the active Q range for a group DOES, however, take account of clamping. Change-Id: I31035e97d18853530b0874b433c1da7703f607d1
2015-10-21Incorrect frame used in KF boost loop.Paul Wilkins
Fixes a bug in the calculation of the boost for key frames. Change-Id: I75e9c96a9e86379239fbbbecb56ccd529783dc7c
2015-09-14For 1 pass: always use the normative filter in vp9_scale_if_required()Marco
The normative (convolve8) filter is optimized/faster than the nonnormative one. Pass usage of scaler (normative/nonomorative) to vp9_scale_if_required(), and always use normative one for 1 pass. Change-Id: I2b71d9ff18b3c7499b058d1325a9554de993dd52
2015-08-31Include vpx_dsp_common.h when using VPXMIN/MAXJohann
Change-Id: I2e387a06484a06301f3cd6600c4ba2f4335b61ee
2015-08-28vp9_firstpass: make vp9_init_subsampling privateJames Zern
Change-Id: I03b2ae99ec2e212c76bf815de7d5745b5c965d57
2015-08-26vpx_dsp_common: add VPX prefix to MIN/MAXJames Zern
prevents redeclaration warnings; vp8 has its own define which will be resolved in a future commit Change-Id: Ic941fef3dd4262fcdce48b73075fe6b375f11c9c
2015-08-14Change vp9_ prefix function names in vpx_scale to vpx_Jingning Han
Change-Id: Iac85902cbbb3e752801dc85de9a3c778e47304aa
2015-08-10Move vp9_systemdependent.h to vpx_ports bitops.h and system_state.hAlex Converse
Use system_state.h in vpx_dsp and remove unneeded includes of vp9_systemdependent.h. Change-Id: I92557ec6dd5aa790160b4f31fe7967db0d7ec3c4
2015-08-06Cosmetic - align format in vp9Jingning Han
Change-Id: I83ed3422f1f4009675ad2f5c4b7236bc7b83b30e
2015-07-14Fixes part of merge regression from adding arf parameters.Debargha Mukherjee
From Change Ibf0c30b72074b3f71918ab278ccccc02a95a70a0 There is still an issue relating to one animated test clip with repeat patterns where this change effectively increase the default maximum arf interval by +1. This can be examined seperately. Change-Id: Idd01d5480fc45202d8a059a0c3afc0997cc5bdd1
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-07-07Move sub pixel variance to vpx_dspJohann
Change-Id: I66bf6720c396c89aa2d1fd26d5d52bf5d5e3dff1
2015-07-07Merge "Error score recalibration for inactive regions."paulwilkins
2015-07-07Merge "ARF Boost correction for inactive regions."paulwilkins
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-07-02Error score recalibration for inactive regions.paulwilkins
Apply a correction to the frame error scores for frames with inactive regions. Change-Id: I217840f2efe7eafed3f5b8ddc7c468f1ca3d923c
2015-07-02ARF Boost correction for inactive regions.paulwilkins
Correct the ARF boost calculations to partly discount inactive or very low energy regions of the image. Examples (formatting bars and 0 energy areas of animated clips). Change-Id: I241af058d10aba8c67a4deca36deb913047d4561
2015-06-26Fixed a variance calculationYaowu Xu
This commit fixed a mistake in variance calculation. Thanks to Xintong for spotting the error. Change-Id: Ia285fc0128c00f0234a73b0a7eba6adc88b8a7de
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-06-01Merge "Fast feedback of bits on undershoot."paulwilkins
2015-05-27Merge "[svc] Make size of empty frame to be 16x16 all the time"Minghai Shang
2015-05-26[svc] Make size of empty frame to be 16x16 all the timeMinghai Shang
Change-Id: Ibab09aa0e8c69cf5efea2f0ec035e5da9cc894b0
2015-05-26Merge "Move variance functions to vpx_dsp"Johann
2015-05-26Move variance functions to vpx_dspJohann
subpel functions will be moved in another patch. Change-Id: Idb2e049bad0b9b32ac42cc7731cd6903de2826ce
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-20Fix issues with mixed ARF and GF groups.paulwilkins
This patch addresses two issues that can occur when the encoder chooses to use a mixture of ARF and GF groups. The first issue relates to a failure to reset the "ARF active" flag correctly when transitioning from coding ARF groups to coding GF groups. This caused some golden frames to be encoded with an incorrect bit rate target as if they were ARF overlay frames. The second issue relates to the encoding of a single short GF group just before a key frame. Where the last group before a key frame is an ARF group we expect the final frame before the key frame to be an low data rate overlay frame. However, when the last group is a GF group, the final frame before the key frame should be a normal frame with a normal bit allocation. This issue had the potential to cause a single poorly coded frame just before a key frame. If that key frame were a forced key frame rather than a real scene cut, this might cause pulsing. Change-Id: Idf1eb5eaf63a231495a74de7899236e1ead9fb00
2015-05-15vp9/encoder: make some functions staticJames Zern
silences missing prototype warnings Change-Id: I3338fcaa67b5dcdf6bf237e8b374db3befd18753
2015-05-13Relocate memory operations for common codeJohann
With the sad functions, and hopefully the variance functions soon, moving to the vpx_dsp location, place the defines used in the reference C code in a common location. Change-Id: I4c8ce7778eb38a0a3ee674d2f1c488eda01cfeca
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-04-22Merge "Modified test for auto key frame detection."paulwilkins
2015-04-22Merge "Limit arf interval for low fpf clips."paulwilkins
2015-04-21Revert "Remove mi_grid_* structures."Scott LaVarnway
(see I3a05cf1610679fed26e0b2eadd315a9ae91afdd6) For the test clip used, the decoder performance improved by ~2%. This is also an intermediate step towards adding back the mode_info streams. Change-Id: Idddc4a3f46e4180fbebddc156c4bbf177d5c2e0d
2015-04-21Modified test for auto key frame detection.paulwilkins
The existing test was triggering a lot of false positives on some types of animated material with very plain backgrounds. These were triggering code designed to catch key frames in letter box format clips. This patch tightens up the criteria and imposes a minimum requirement on the % blocks coded intra in the first pass and the ratio between the % coded intra and the modified inter % after discounting neutral (flat) blocks that are coded equally well either way. On a particular problem animation clip this change eliminated a large number of false positives including some cases where the old code selected kf several times in a row. Marginal false negatives are less damaging typically to compression and in the problem clip there are now a couple of cases where "visual" scene cuts are ignored because of well correlated content across the scene cut. Replaced some magic numbers related to this with #defines and added explanatory comments. Change-Id: Ia3d304ac60eb7e4323e3817eaf83b4752cd63ecf
2015-04-16Limit arf interval for low fpf clips.paulwilkins
This patch limits the maximum arf interval length to approximately half a second. In some low fps animations in particular the existing code was selecting an overly long interval which was hurting visual quality. For a sample problem test clip (360P animation , 15fps, ~200Kbit/s) this change also improved metrics by >0.5 db. There may be some clips where this hurts metrics a little, but the worst case impact visually is likely to be less than having an interval that is much too long. On more normal material at 24 fps or higher, the impact is likely to be nil/minimal. Change-Id: Id8b57413931a670c861213ea91d7cc596375a297
2015-04-07Improve accuracy of rate control in CQ modeDebargha Mukherjee
Modifies a special handling that improves rate control accuracy in the constrained quality mode, when the undershoot and overshoot limits are set tighter. Change-Id: If62103f0ef3ed1cac92807400678c93da50cf046
2015-03-24Merge "Enable group adaptive max q by default."paulwilkins
2015-03-23Enable group adaptive max q by default.paulwilkins
Set the GF group adaptive max Q compile flag to 1 by default. This change has a quite big visual impact in some clips and also contributes to tighter rate control. For short test clips that have consistent content the impact is quite small on metrics but for more varied long form clips there is a drop in overal psnr but a sharp rise in average psnr caused by greater expenditure on some easier sections and tighter rate clipping in hard sections. In chunck'ed encodes some of the effect will already be present due to the independent rate control in each chunk but this change takes the control down to a smaller scale. yt hd +10.67%, - 3.77%, -1.56% yt +9.654%, - 3.6%, - 1.82% std hd +0.25%, -0.85%, -0.42% derf +0.25%, - 1.1%. - 0.87% Change-Id: Ibbc39b800d99d053939f4c6712d715124082843e
2015-03-20Revised rd adjustment for variance.paulwilkins
Revised adjustment for rd based on source complexity. Two cases: 1) Bias against low variance intra predictors when the actual source variance is higher. 2) When the source variance is very low to give a slight bias against predictors that might introduce false texture or features. The impact on metrics of this change across the test sets is small and mixed. derf -0.073%, -0.049%, -0.291% std hd -0.093%, -0.1%, -0.557% yt +0.186%, +0.04%, - 0.074% ythd +0.625%, + 0.563%, +0.584% Medium to strong psycho-visual improvements in some problem clips. This feature and intra weight on GF group length now turned on by default. Change-Id: Idefc8b633a7b7bc56c42dbe19f6b2f872d73851e
2015-03-13Merge "Shorten GF/arf interval in hard scenes."paulwilkins
2015-03-11Shorten GF/arf interval in hard scenes.paulwilkins
This patch accounts in the first pass stats for blocks that while not coded as intra, are complex and have an intra error / best error ratio below a threshold. The modification shortens the GF arf interval for a particular class of content that contains a lot of blocks matching the above criteria. (In one short problem test sequence the average interval dropped from about 14-15 to 10-11) The change results in small net gains in metrics results for the Yt(~0.2%) and yt-hd (~0.5%) sets and is approximately neutral for the other test sets. The change is currently shielded by a flag and off by default pending verification that it does not cause other regressions in tests on a wider YT test set. Change-Id: I6b803daa6a4ac09a6f428fb3a18be1ecedd974b7
2015-03-09Allow q adjustment for VPX_CQ and VPX_CBR.paulwilkins
Adjustment previously only enabled in VBR mode. This patch allows adjustment of min and max q for CBR and adjustment of max q only for CQ mode. Change-Id: Id5e583f3d50453cd544fc57249acacd946457482
2015-03-04Small rationalization of code in vp9_first_passAdrian Grange
Change-Id: I87cc0e038171c60a957298827e312fead500f7fb
2015-03-04Make encoder buffer allocation dynamicAdrian Grange
Frame buffers are now allocated dynamically on-demand. Entries in the reference frame map, cm->ref_frame_map, may now be set to -1 (INVALID_IDX) to indicate that there is not a valid reference buffer in that "slot". All slots in the reference frame map are now initialized to the empty state (-1) and each buffer is initialized to have a reference count of 0. Change-Id: Id1afe98de98db4ae8b2dfefed7889c3b28c68582
2015-02-23Account for rate error in GF group Q calculation.paulwilkins
When GF group adaptive maxQ is enabled this patch accounts somewhat for accumulated error in the rate control. This improves accuracy quite a bit on many clips especially when there is overshoot. Examples when the overshoot and undershoot command line parameters are set to 100: Hall @ 1200 overshoot is reduced from 67-24%. Akiyo @ 400 undershoot is reduced from 28%-15%. Setting a lower value for undershoot or overshoot still reduces the error further. Impact on metrics is mixed with some gains in average psnr but generally a little lower (e.g. 0.5%) on overall and ssim. The GF group adaptation is still off by default in this patch. Compared to with the head, enabling this mode now gives big average psnr gains on the YT sets (e.g. YT_HD >11.2%), a drop in overall PSNR (YT-HD 3.9%) and a smaller drop or neutral for SSIM. Change-Id: If4b32cd0740d3fb941317b374f9c2951954eee90
2015-02-19Fix control string in firstpass stats fprintfAdrian Grange
20 items in the control string but only 19 arguments. Change-Id: I51dab9aa1c58c653b52395005a9cb41f09feb484
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-30Try again to merge branch 'frame-parallel' into master branch.hkuang
In frame parallel decode, libvpx decoder decodes several frames on all cpus in parallel fashion. If not being flushed, it will only return frame when all the cpus are busy. If getting flushed, it will return all the frames in the decoder. Compare with current serial decode mode in which libvpx decoder is idle between decode calls, libvpx decoder is busy between decode calls. Current frame parallel decode will only speed up the decoding for frame parallel encoded videos. For non frame parallel encoded videos, frame parallel decode is slower than serial decode due to lack of loopfilter worker thread. There are still some known issues that need to be addressed. For example: decode frame parallel videos with segmentation enabled is not right sometimes. * frame-parallel: Add error handling for frame parallel decode and unit test for that. Fix a bug in frame parallel decode and add a unit test for that. Add two test vectors to test frame parallel decode. Add key frame seeking to webmdec and webm_video_source. Implement frame parallel decode for VP9. Increase the thread test range to cover 5, 6, 7, 8 threads. Fix a bug in adding frame parallel unit test. Add VP9 frame-parallel unit test. Manually pick "Make the api behavior conform to api spec." from master branch. Move vp9_dec_build_inter_predictors_* to decoder folder. Add segmentation map array for current and last frame segmentation. Include the right header for VP9 worker thread. Move vp9_thread.* to common. ctrl_get_reference does not need user_priv. Seperate the frame buffers from VP9 encoder/decoder structure. Revert "Revert "Revert "Revert 3 patches from Hangyu to get Chrome to build:""" Conflicts: test/codec_factory.h test/decode_test_driver.cc test/decode_test_driver.h test/invalid_file_test.cc test/test-data.sha1 test/test.mk test/test_vectors.cc vp8/vp8_dx_iface.c vp9/common/vp9_alloccommon.c vp9/common/vp9_entropymode.c vp9/common/vp9_loopfilter_thread.c vp9/common/vp9_loopfilter_thread.h vp9/common/vp9_mvref_common.c vp9/common/vp9_onyxc_int.h vp9/common/vp9_reconinter.c vp9/decoder/vp9_decodeframe.c vp9/decoder/vp9_decodeframe.h vp9/decoder/vp9_decodemv.c vp9/decoder/vp9_decoder.c vp9/decoder/vp9_decoder.h vp9/encoder/vp9_encoder.c vp9/encoder/vp9_pickmode.c vp9/encoder/vp9_rdopt.c vp9/vp9_cx_iface.c vp9/vp9_dx_iface.c This reverts commit a18da9760a74d9ce6fb9f875706dc639c95402f5. Change-Id: I361442ffec1586d036ea2e0ee97ce4f077585f02