Commit Graph

6920 Commits

Author SHA1 Message Date
Marco
a40fa1f95d vp9: Reset rc flags on some configuration changes.
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-12-13 10:41:38 -08:00
Paul Wilkins
94eaecaa91 Merge "Bug fix for second reference stats." 2017-12-12 11:56:10 +00:00
Jerome Jiang
c1e511fd82 vp9 svc: Allow denoising next to highest resolution.
Denoise 2 spatial layes at most.

Add noise sensitivity level 2 for vp9 such that applications can control
whether to denoise the second highest spatial layer.

Add tests to cover this case.

Change-Id: Ic327d14b29adeba3f0dae547629f43b98d22997f
2017-12-11 15:20:19 -08:00
paulwilkins
f1ce050f44 Bug fix for second reference stats.
Immediately following a key frame the trailing second reference
error in the first pass stats will be based on a reference frame from
the prior key frame group and will thus usually be much larger.

This fix eliminates that effect (which typically triggers a short arf
group immediately after a key frame). It also changes the accounting
for the first frame in each new arf group.

This change gives large gains on a couple of clips that contain mid
sequence key frames (e.g. 6% on 1080P tennis). Overall there was
a net gain in PSNR and PSNR-HVS ~(0.05- 0.4%) and mixed results for
SSIM (+/- 0.2%).

Change-Id: I8e00538ac2c0b5c2e7e637903cac329ce5c2a375
2017-12-08 10:05:36 +00:00
Marco
3562d6b0a2 vp9-svc: Set downsampling filter for VGA layer.
Downsampling filter for SVC was set to subsample (phase 0)
for HD -> VGA, and bilinear averaging (phase 8) for VGA -> QVGA.
This change makes it bilinear averaging for HD -> VGA.

Given the recent commit 9f9d4f8, quality is improved with
this change: avgPSNR/SSIM up ~1-3% on HD clips in RTC set.
Speed decrease of ~1% for 3 layer SVC.

Change-Id: If834a320e372b8b922a6bf7cab4227703b1beae6
2017-12-06 12:01:24 -08:00
Marco Paniconi
575c1933ea Merge "vp9: Nonrd-pickmode: move some early exits up." 2017-12-06 19:18:51 +00:00
Hui Su
2e44f16443 Merge "Add max luma picture width/height constraint in VP9 level" 2017-12-06 18:46:19 +00:00
Marco
33953f310e vp9: Nonrd-pickmode: move some early exits up.
Move the early exit checks on usable_ref_frame and
skip_ref_find_pref up before the check on flag_svc_subpel.
The code under flag_svc_subpel requires frame_mv to be set
for the golden/spatial reference, which is only set if the
both those exits don't pass.

No change in behavior.

Change-Id: Id304276c745eeb389ff85fa2dcf510d5976bc413
2017-12-06 10:18:44 -08:00
Marco
9f9d4f8dc9 vp9-svc: Allow for nonzero motion on spatial reference.
For nonrd pickmode on a given spatial layer, the spatial
(golden) reference was always only using zeromv for prediction.
In this patch if the downsampling filter used for generating
the lower spatial layer is an averaging filter (nonzero phase),
we allow for subpel motion on the spatial (golden) reference to
compensate for the shift. This is done by forcing the testing of
nonzero motion mode to compensate for spatial downsampling shift.

Improvement for cases where the downsampling is averaging filter.
In the current code this is only done for generating
resolutions <= QVGA.

Improvement for avgPSNR/SSIM on RTC set for speed 7: ~1.2%.
Gain is larger (~2-3%) for VGA clips with 2 spatial layers.
~1% speed slowdown for 3 layer SVC on mac.

Change-Id: I9ec4fa20a38947934fc650594596c25280c3b289
2017-12-05 22:41:07 -08:00
Hui Su
07b12aad77 Add max luma picture width/height constraint in VP9 level
BUG=b/65412009

Change-Id: I9e1478dcbd2ef9e97f5f8fb5a1c733b5f5cdf396
2017-12-01 16:29:40 -08:00
Marco
8d0e7ac29a vp9-svc: Set num_inter_modes in non-rd pickmode.
Set num_inter_modes based on ref_mode_set_svc, which is
smaller set than ref_mode_set (which may use alt-ref).

No change in behavior.

Change-Id: I31169bb09028db230552c6fca0a86959d1ade692
2017-12-01 10:30:45 -08:00
Marco Paniconi
c22ab8ab9f Merge "Nonrd-pickmode: avoid duplicate computation of UV predictor." 2017-12-01 00:23:52 +00:00
Marco
2e701f7c29 Nonrd-pickmode: avoid duplicate computation of UV predictor.
Avoids duplicate computation of UV predictor.

Bit-exact when static_threshold is zero.
Small/neutral difference on RTC set with nonzero static_threshold
(since UV predictor won't be skipped with this change).

Small speed gain, ~1-2%, at speed 8.

Change-Id: Iba8d22a307768b391e29d63c9826aac5a4d9c285
2017-11-30 12:41:58 -08:00
Marco
b409863c48 Fix to copy partition.
Update the prev_partition on early exits in
choose_partitioning().

Change-Id: I382ffcab8e647c00b14283d15c3dd11bb0ac6f50
2017-11-30 10:27:34 -08:00
Jingning Han
9116e3d957 Merge "Add PSNR Cb and Cr metric to opsnr.stt" 2017-11-29 22:56:47 +00:00
Marco Paniconi
3437fe484a Merge "vp9-svc: Don't allow encode_breakout on golden ref." 2017-11-29 22:41:31 +00:00
Marco
49f51af4c9 vp9-svc: Don't allow encode_breakout on golden ref.
For 1 pass cbr SVC: GOLDEN is the spatial reference,
better not to check for encoder_breakout on this reference.

Small positive ~0.075% (mostly neutral) gain in avgPSNR/SSIM metrics.
No observed change in encoder speed.

Change-Id: Ib337f16d6771105bf06384c6a23ad047fc690418
2017-11-29 13:58:43 -08:00
Marco
0e94522338 vp9-svc: Clean conditon for allowing copy_partition.
Make condition explicit on non_reference_frame.

No change in behavior.

Change-Id: Iec5068bccd93c7c7be67634c5c090580b2dbb20d
2017-11-29 13:19:09 -08:00
Kyle Siefring
3ae909b0f9 Merge "Remove unnecessary includes of emmintrin_compat.h" 2017-11-29 19:14:45 +00:00
Kyle Siefring
a60da3a2eb Remove unnecessary includes of emmintrin_compat.h
Change-Id: Ie60381a0c6ee01f828cd364a43f01517f4cb03e9
2017-11-29 11:48:24 -05:00
Jingning Han
9bd3f1e30d Add PSNR Cb and Cr metric to opsnr.stt
Change-Id: I24e1741c00f9514647c7db2758a7ababd4e96932
2017-11-28 20:03:59 -08:00
Marco
f0b4868625 vp9-svc: Fix condition for setting downsampling filter.
Use (width * height) for setting downsampling filter type.

Change-Id: If4acfde7ff9339e0584155f8a4d15b2f134211f2
2017-11-28 16:28:29 -08:00
Marco
cbe62b9c2d vp9-svc: Fix to the layer buffer settings.
For the case when the number of temporal layers > 1,
the buffer levels (starting/optimal_buffer_level,
and maximum_buffer_size) were not scaled properly.

In vp9_update_layer_context_change_config():
when setting the layer-buffer levels, fix is to scale
the layer-target_bandwidth by the target_bandwidth
(which is the full stream bandwidth) instead of the
spatial_layer_target.

This is needed because prior to the call
vp9_update_layer_context_change_config(), set_rc_buffer_sizes()
is called which sets the buffer levels based on target bandwidth
(which is the full bandwidth for the SVC stream).

This fix properly sets the layer-buffer levels based on the
layer-bandwidth, and leads to better rate targeting.

Small/neutral change in avgPSNR/SSIM metrics on RTC set.

Change-Id: Ic0f4f7f3487c37b9a9adb4781ae5edfed7140a57
2017-11-26 22:17:48 -08:00
Vlad Tsyrklevich
bc29863b96 [CFI] Remove function pointer casts
Control Flow Integrity [1] indirect call checking verifies that function
pointers only call valid functions with a matching type signature. This
change eliminates function pointer casts to make libvpx CFI-safe.

[1] https://www.chromium.org/developers/testing/control-flow-integrity

Change-Id: I7e08522d195a43c88cda06fa20414426c8c4372c
2017-11-20 16:36:29 -08:00
Marco
559166acfe vp9-svc: Enbale scale partition reference frames.
For reference frames: enable scale partition for
superblocks with low source sad or if bsize on lower-resoln
is at least 32x32.

Keep feature disabled for base temporal layer.

Small regression in avgPNSR/SSIM metrics, ~0.5-1%.
Speedup ~2-3% on mac for SVC (3 spatial/3 temporal layers) at speed 7.

Change-Id: I5987eb7763845b680059128b538bb5188be0cca5
2017-11-17 14:52:20 -08:00
Paul Wilkins
849b3c238d Merge "Disable allow_partition_search_skip for speed 2." 2017-11-17 10:34:56 +00:00
Paul Wilkins
c66eeab30e Merge "Code cleanup." 2017-11-17 10:34:46 +00:00
Paul Wilkins
55eacca945 Merge "Remove decay_accumulator clause from alt ref breakout." 2017-11-17 10:34:37 +00:00
Paul Wilkins
4bd2a59e9b Merge "Add clause to alt ref group breakout." 2017-11-17 10:34:26 +00:00
paulwilkins
44473e7eb9 Disable allow_partition_search_skip for speed 2.
When allow_partition_search_skip  is set the two pass code
can optionally skip the partition search in the rd loop if the image
appears static (based on selection of 0,0 motion).

Unfortunately 0,0 motion does not necessarily mean that there are
no meaningful changes or that motion or intra modes will not be selected
in the second pass.

Disabling "allow_partition_search_skip" may hurt the encode speed a little
for a small number of clips but can have a big impact on compression.
The most notable example of this in our test sets is "bridge_close_cif"
where this change gives a gains of 18%, 12% and 16% in opsnr, ssim and
psnr-hvs.

Change-Id: I765e288b5c0cd82bce00a148e7653a21e9203024
2017-11-16 16:17:57 +00:00
Jerome Jiang
1aea1675c0 vp9 svc: Rework/fix scale partitioning on boundary.
Enable partition copy on boundary and scale blocks along the boundary.
Rename copy_partition_svc to scale_partition_svc.

Do not copy if the block crosses the boundary.

Change-Id: I37a04d48f11b15c4ea67facd7631193ec2f62150
2017-11-15 20:34:58 -08:00
paulwilkins
05302360c9 Code cleanup.
Removal of parameters to and code in calc_frame_boost() that is no
longer required.

No change to results from previous patch.

Change-Id: Ic92da35613fdc247d22fddf24d09679fc5329017
2017-11-15 17:07:28 +00:00
paulwilkins
03c1a827ac Remove decay_accumulator clause from alt ref breakout.
The decay accumulator clause covers similar ground to the
new clause that tests the accumulated second reference error
so it has been removed to reduce complexity.

Change-Id: I4ec1cce32d72bd4ee463ad7def2831a68447d525
2017-11-15 16:58:05 +00:00
paulwilkins
607e45f420 Add clause to alt ref group breakout.
Add a clause to the breakout test for alt ref groups that
examines the size of the accumulated second reference
frame error compared to the cost of intra coding.

This clause causes a reduction in the average group length for many
clips. Alongside the change to the group length the minimum
boost is increased.

On balance the results are positive for psnr and psnr-hvs
but is negative for ssim/fast ssim for the smaller image formats.

Strong gains on some harder clips (eg ducks take off (midres) ~20%,
husky (lowres) 6-17%. Most of the negative cases are lower motion
clips. Subsequent patch hopefully will help with those.

Change-Id: Ic1f5dbb9153d5089e58b1540470e799f91a65dc4
2017-11-15 16:40:12 +00:00
Marco
b3c93d60c2 vp9-svc: Fix flag for usage of reuse-lowres partition
Fix/cleaup the conditioning for usage of the reuse-lowres
partition feature.

Replace the non-reference condition with the top temporal
layer, and put this condition in the speed feature.

This prevents doing update_partition_svc() on every
VGA frame, instead it will now only do update for VGA in
the top temporal layer frames.

Also this makes it easier to test/enable this feature
for lower layer temporal frames.

Change-Id: Ia897afbc6fe5c84c5693e310bcaa6a87ce017be5
2017-11-14 20:08:10 -08:00
paulwilkins
a73cee2870 New content type to improve grain retention.
For new VP9 only content type adjust  the rate distortion and ARF
filter based on the relative spatial variance of the source and
reconstruction.

In regards to the RD loop the method favors modes where the
reconstruction variance is similar to the source variance. However it
is currently only applied to regions where the source variance is quite
low.

For very low variance blocks it applies a further bias against intra
coding and large prediction block sizes (the later in particular limit
the usefulness of the loop filter).

The final part of this change is to lower the strength of the ARF
filter for blocks where the source has very low spatial variance, to
encourage some low amplitude texture or noise to pass through
the filter.

This change improves the retention of film grain and fine noise /
texture in spatially flat regions, but as expected causes a significant
drop in PSNR on many clips. This is to be expected because similar
but misaligned noise or texture will give a lower PSNR than a flat
noise free reconstruction. However, it is worth noting that most clips
show a strong gain in FAST SSIM.

The features are enabled on the vpxenc command line by setting
--tune-content=film.

VPX_ENCODER_ABI_VERSION bumped for this change and cvbr.

Change-Id: I26a4e4edfa3dc5cacead82fa701fe7a9118ccd0a
2017-11-13 16:57:23 +00:00
paulwilkins
55fc4d95af Small parameter clean up.
Removed three parameters that are no longer needed in calls
to calc_arf_boost() and associated minor changes.

No impact on encode results.

Change-Id: Ieaf31d0d2e1990b99cf69647170145a1bbfbb9fb
2017-11-13 16:53:57 +00:00
Paul Wilkins
2eddfb46a9 Merge "Fix to frames considered in arf boost calculation." 2017-11-13 16:36:43 +00:00
Paul Wilkins
f5817fa612 Merge "CVBR command line option." 2017-11-13 16:32:39 +00:00
Scott LaVarnway
8c7213bc00 Merge "vpx: [x86] add vp9_block_error_fp_avx2()" 2017-11-10 00:45:47 +00:00
Marco
6c0011a255 vp9-svc: Avoid minmax variance for non-reference frames.
For choose_partitioning (speed >= 6): avoid computation
of minmax variance for non-reference frames in SVC.

Existing condition only avoided this for speed >= 8.
Combine that existing logic with non-reference condition.

Small speedup (~0.5-1%) for 3 layer SVC,
neutral change on avgPSNR/SSIM metrics.

Change-Id: I3e9f3a1af0647b15e475cf170d9402908d672ee5
2017-11-09 16:27:27 -08:00
Jerome Jiang
fdb054a05d vp9: SVC feature to use partition from lower resolution.
For SVC with 3 spatial layers:
Add feature to copy/upscale partition from middle spatial layer
to the upper/highest resolution, when superblock sad is not high.

Enabled for speed >= 7 and only for non-reference frames.

Speedup ~3-4%, small loss in avgPNSR/SSIM of ~1%.

Change-Id: I7f0a2716c0fde28bade0f86159d11b7e31d6ab8d
2017-11-09 14:16:50 -08:00
Scott LaVarnway
62ab5e99c1 vpx: [x86] add vp9_block_error_fp_avx2()
SSE2 asm vs AVX2 intrinsics speed gains:
blocksize   16: ~1.00
blocksize   64: ~1.17
blocksize  256: ~1.67
blocksize 1024: ~1.81

Change-Id: I2a86db239cf57e3ff617890ccb2d236aba83ad5e
2017-11-09 05:02:31 -08:00
paulwilkins
d6e29868ac Fix to frames considered in arf boost calculation.
For a chosen interval "i" the existing arf boost calculation examined frames
+/- (i-1) frames from the current location in the second pass.

This change checks to make sure that the forward search does not extend
beyond the next key frame in the event that the distance to the next key
frame is < (i - 1).

Small metrics gains on all our  test sets but these are localized to a few clips
(e.g. midres set psnr-hvs sintel -2.59% but overall average was only -0.185%)

Change-Id: I26fc9ce582b6d58fa1113a238395e12ad3123cf6
2017-11-09 10:46:10 +00:00
paulwilkins
93e83fd7cf CVBR command line option.
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-11-08 10:41:04 +00:00
Marco
6fbc354c97 Nonrd_pickmode: avoid computing UV cost when early_term is set.
For nonrd_pickmode: if early_term is set there should be
no need to include UV in rdcost (when color_sensitivity is set).

Neutral change on RTC and RTC_derf metrics, for speed >= 5.
No change for ytlive metrics.

Very small speed gain (~0.5%) on some clips with strong color content.

Change-Id: Ifc00928ecd935fc71e94935ceef0ae7481249f07
2017-11-06 10:22:14 -08:00
Marco
eb7d431cb5 Compound prediction mode for nonrd pickmode.
Allow for compound prediction mode in nonrd_pickmode for ZEROMV.
For real-time encoding, 1 pass with non-zero lag-in-frames.

Added speed feature to control the feature.
Enabled for speed >=6 for now, under VBR mode.

avgPSNR/SSIM metrics positive on ytlive set, for speed 6:
some clips up by ~3-5%, some clips neutral gain, average gain
across clips is ~1%.

Small/negligible decrease in speed.

Change-Id: I7a60c7596e69b9a928410c5ee2f9141eecd8613d
2017-11-03 10:13:05 -07:00
Jerome Jiang
3ba9a2c8b2 Merge "vp9: Move allocation of vt2 after early exits." 2017-11-01 16:58:01 +00:00
Jerome Jiang
34805d6d0d vp9: Move allocation of vt2 after early exits.
Remove the memory deallocation on the early exits.

Change-Id: I00b4a814ae6705105ecab89644d055ca3311d9f4
2017-10-31 17:04:04 -07:00
Jerome Jiang
0c84b9b703 Merge "vp9: Reduce stack usage of choose_partitioning." 2017-10-31 21:42:18 +00:00
Jerome Jiang
18b470f486 vp9: Reduce stack usage of choose_partitioning.
Move vt2 to heap.
Reduce the stack usage from ~87K to ~44K.

BUG=b/68362457

Change-Id: I8f5f93712934d59a8cc4564378172d409a736a2e
2017-10-31 13:10:27 -07:00
Jerome Jiang
c77822615e Merge "vp9: Reduce stack usage of choose_partioning." 2017-10-30 23:39:41 +00:00
Jerome Jiang
cc47231187 vp9: Reduce stack usage of choose_partioning.
Change type of sum_square_error from int64_t to uint32_t.
Change type of sum_error from int64_t to int32_t.

This reduces the stack usage from ~131K to ~87K.

BUG=b/68362457

Change-Id: I147d7c7b226bceb4f0817bb86848e1fa9d9ac149
2017-10-30 13:53:20 -07:00
Marco
0738d90169 vp9-svc: Allow for adapt_rd_thresh with row-mt.
Set adaptive_row_thresh_mt = 1 at speed >= 7,
for svc when multi-threading is used with row-mt.
This allow the adaptive_rd_thresh feature to be used
in the nonrd-pickmode.

~1-2% speedup for SVC encoding with small quality
loss (< 0.6%) on RTC set.

Change-Id: Iab9878dff117bccdaef3e4d0645165db9808cdfc
2017-10-23 11:47:18 -07:00
Paul Wilkins
199971d606 Merge "Corpus VBR tweak for undershoot." 2017-10-19 10:07:45 +00:00
Paul Wilkins
0c493cbe2b Merge "Increase precision of some debug stats output for corpus VBR." 2017-10-19 10:07:30 +00:00
Paul Wilkins
d8c34a2552 Merge "Prevent double application of min rate in two pass." 2017-10-19 10:06:33 +00:00
Linfeng Zhang
9336e01621 Merge changes I17fff122,Ic149e3cb
* changes:
  Add 4 to 3 scaling SSSE3 optimization
  Test extreme inputs in frame scale functions
2017-10-17 16:03:29 +00:00
Linfeng Zhang
580d32240f Add 4 to 3 scaling SSSE3 optimization
Note this change will trigger the different C version on SSSE3 and
generate different scaled output.

Its speed is 2x compared with the version calling vpx_scaled_2d_ssse3().

Change-Id: I17fff122cd0a5ac8aa451d84daa606582da8e194
2017-10-16 15:42:42 -07:00
Marco
a9248457b1 Adjust threshold in gf_boost for 1 pass vbr
Small inncrease the sad_thresh1, avoids some false
detection of possible scene changes within lag.

Small improvement in few clips on ytlive, otherwise neutral change.

Change-Id: Ia79b53bb657bbce65a7aac7d20666b6373d5af8b
2017-10-13 15:33:51 -07:00
Paul Wilkins
12df840777 Merge "Further Corpus VBR change." 2017-10-13 15:59:58 +00:00
Paul Wilkins
eaa593d293 Merge "Corpus Wide VBR test implementation." 2017-10-13 15:59:45 +00:00
paulwilkins
8842ee0b0d Corpus VBR tweak for undershoot.
In cases of strong undershoot adjust Q range down faster.

Change-Id: I84982beceb3c9b6dc50e52e4a6e891c7dd395d03
2017-10-13 10:27:15 +01:00
Marco Paniconi
28d1c0535d Merge "Adjust to scene detection for 1 pass vbr." 2017-10-12 19:36:33 +00:00
Marco
a673b4f4af Adjust to scene detection for 1 pass vbr.
Expose the threshold for setting key frame on cut,
and increase it for speed 5.
Also small adjustment to min_thresh.

No change in overall metrics or fps.
Small quality improvement and lower encode time on scene cuts.

Change-Id: I36e06ff3b26b6c29aede39c23fce454525fc9026
2017-10-12 10:59:23 -07:00
paulwilkins
2b247ae91c Increase precision of some debug stats output for corpus VBR.
Change-Id: I75841797cc0c215781b5b36e3a3e9f4b0e35ba63
2017-10-12 10:07:21 +01:00
Jerome Jiang
288890cd43 vp9: use nonrd pick_intra for small blocks on keyframes.
Keyframe encoding is more than 2x faster.
Disabled on Speed 8.

Change-Id: I2157318b6ac8253fa5398322c72d98cd7fa9b2b6
2017-10-11 21:38:01 -07:00
paulwilkins
416b7051d7 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
2017-10-11 18:00:44 +01:00
Linfeng Zhang
16166bfdaa Add 4 to 1 scaling x86 optimization
Change-Id: I51c190f0a88685867df36912522e67bdae58a673
2017-10-10 16:24:06 -07:00
Marco
017257a317 Adjustment to scene detection and key frame.
For 1 pass vbr: use higher threshold on avg_sad
and force key frame under scene cut detection if
above the threshold. Allow it for speed >= 6 for now,
since it does not use the full nonrd_pickmode partition
(as in speed 5).

Improves quality somewhat on scene cut frames.
Neutral on overall metrics and fps for speed 6 on
ytlive set.

Change-Id: I12626f7627419ca14f9d0d249df86c7104438162
2017-10-10 11:20:05 -07:00
Linfeng Zhang
963cc22cef Merge changes I9d4c1af5,I882da3a0
* changes:
  Rename some inline functions in NEON scaling
  Generalize 2:1 vp9_scale_and_extend_frame_ssse3()
2017-10-10 17:29:50 +00:00
paulwilkins
06d231c9fa Further Corpus VBR change.
Change to the bit allocation within a GF/ARF group.

Normal VBR and CQ mode allocate bits to a GF/ARF group based of the mean
complexity score of the frames in that group but then share bits evenly between
the "normal" frames in that group regardless of the individual frame complexity
scores (with the exception of the middle and last frames).

This patch alters the behavior for the experimental "Corpus VBR" mode such that
the allocation is always based on the individual complexity scores.

Change-Id: I5045a143eadeb452302886cc5ccffd0906b75708
2017-10-10 10:41:35 +01:00
paulwilkins
741bd6df4f Corpus Wide VBR test implementation.
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-10 10:40:44 +01:00
Linfeng Zhang
27d21a3d13 Rename some inline functions in NEON scaling
Change-Id: I9d4c1af53d57f72fc716bacbe3b0965719c045ac
2017-10-09 11:23:00 -07:00
Linfeng Zhang
e1ae3772da Merge "Update vp9_scale_and_extend_frame_ssse3()" 2017-10-09 16:20:00 +00:00
Marco Paniconi
5bc4c37a89 Merge "Revert "Speed >=5 real-time: add TM intra mode for high_source_sad."" 2017-10-06 22:41:34 +00:00
Marco Paniconi
bcbc6ed82d Revert "Speed >=5 real-time: add TM intra mode for high_source_sad."
This reverts commit 9311ef18b4.

Reason for revert:
Notice small regression in some clips.
Will revisit in another change.

Original change's description:
> Speed >=5 real-time: add TM intra mode for high_source_sad.
> 
> Small/neutral change in metrics or speed for ytlive.
> Some improvement in quality on frames with big content change.
> 
> Change-Id: Ib3b0703a5f28ea6710e90324436e27598ab7384d

TBR=marpan@google.com,builds@webmproject.org,jianj@google.com

Change-Id: I9d8ec5195bb05ddf329d325699355185affb9b13
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
2017-10-06 22:14:56 +00:00
Marco
e405eb06b1 Adjust threshold in scene detection
For 1 pass vbr: increase min_thresh slightly, and also add
condition on golden/arf update for using full nonrd_pick_partition.

Reduces possible false detection for scene cut detection.

Neutral/small change in metrics or speed for speed 5.

Change-Id: I388f4d9a56e3cc763e0148338c1bc0381e58ad76
2017-10-06 11:08:56 -07:00
Marco
9311ef18b4 Speed >=5 real-time: add TM intra mode for high_source_sad.
Small/neutral change in metrics or speed for ytlive.
Some improvement in quality on frames with big content change.

Change-Id: Ib3b0703a5f28ea6710e90324436e27598ab7384d
2017-10-05 23:07:03 -07:00
Marco
18262a8576 Adjust threshold for adapt_partition for speed 6.
Lower SAD threshold to select non_rd pickmode partition
at superblock level more often.
Small gain in metrics, small/negligible decrease in speed.

Change-Id: I0f728236b91a604e4ca7e02039adc54d5985c4dc
2017-10-04 18:04:09 -07:00
Marco
4bc1fc58b6 Avoid nonrd_pick_partition for speed >= 6.
For 1 pass vbr speed >= 6: when REFERENCE_PARTITION is selected,
avoid doing the full nonrd_pickmode based partition.
No change in overall metrics or speed.
Reduces encode times on scene cuts by 10-20%.

Change-Id: I0310b1610cc1c83793a509e0a9059840e8f18308
2017-10-04 15:31:54 -07:00
Linfeng Zhang
127864deb3 Generalize 2:1 vp9_scale_and_extend_frame_ssse3()
Change-Id: I882da3a04884d5fabd4cd591c28682cbb2d76aa5
2017-10-04 12:35:39 -07:00
Linfeng Zhang
b809442521 Update vp9_scale_and_extend_frame_ssse3()
Change-Id: I22622faebfcc36f7a4d1f37e3800ae8ab87c8cd4
2017-10-04 12:32:30 -07:00
Marco
77e51e2035 Modify early exit for alt_ref in nonrd_pickmode.
For 1 pass vbr mode:
On no-show_frame/ARF: instead of skipping alt_ref_frame
completely in mode testing, allow for checking (0, 0) on alt_ref.

Small gain in metrics, ~0.18%, no change in speed.

Change-Id: I32a3c24faca64ab70dd5091071a0dc301db7dd1e
2017-10-04 11:53:39 -07:00
Marco
98dbf31c87 Enable arf usage for speed >= 6, 1 pass vbr.
For speed 6 on ytlive set:
On average, speed slowdown ~5%, quality gain ~2%.

Change-Id: Ia18237cc1d52c54d7e2cb3c71f571cf37ef61b44
2017-10-03 17:18:33 -07:00
Marco
ab2bd340ac vp9: 1 pass vbr: Limit qpdelta on high_source_sad.
For 1 pass vbr: when significant content/scene change is detected
(high_source_sad = 1) reduce/turnoff the additional qdelta on the
active_worst_quality. This helps somewhat to reduce the occurrence
of large frame sizes and large encode times.
Allow it only when use_altef_onepass is enabled.

Neutral/no change on metrics.

Change-Id: I1dd97dd2ab892d65f707b841b27a5de300b714ea
2017-10-03 16:27:17 -07:00
Marco
c8678fb7f3 Use adapt_partition for ARF in 1 pass.
For speed 6 real-time mode: use adapt_partition
on ARF frame instead of REFERENCE_PARTITION (which is slower).
This requires enabling compute_source_sad_onepass for no-show_frames.

Speedup of ~3-5% on some clips that heavily use ARF,
small loss (~0.2%) in quality on ytlive set.

Change-Id: Ib50acc97df06458244a6ac55d2bd882c30012536
2017-10-03 11:49:55 -07:00
Marco Paniconi
fe7b869104 Merge "ARF in 1 pass vbr: modify skip ref_frame in nonrd_pickmode." 2017-10-03 03:01:14 +00:00
Marco
33e10dfa7e ARF in 1 pass vbr: modify skip ref_frame in nonrd_pickmode.
Speedup of ~2-3% on 1080p clips speed 6.
Neutral/negligible loss in metrics on ytlive.

Change-Id: I7ac47a4d8b58c566920bae29a94a0e8d59c36dee
2017-10-02 19:04:03 -07:00
Linfeng Zhang
0e55b0b0a7 Add 4 to 3 scaling NEON optimization
Speed comparing with the one calling vpx_scaled_2d_neon()
  ~1.7 x in general
  ~2.8x for BILINEAR filter

BUG=webm:1419

Change-Id: I8f0a54c2013e61ea086033010f97c19ecf47c7c6
2017-10-02 15:04:09 -07:00
Linfeng Zhang
2c560c3c22 Specialize 4 to 3 frame scaling in C
Scale 3x3 block instead of 16x16 block in each loop. Disabled by
default.

Benefits:
1. Reduced number of different phase_scaler from 16 to 3.
   Optimization code will be smaller and faster.
2. Maximum phase_scaler drifting will be reduced from 5/16 to 1/24.
   (The drifting is 1/(3*16) in each step.)

BUG=webm:1419

Change-Id: I59a1f7496d89a1b090498c935d30cfcf1d0c282b
2017-10-02 11:56:15 -07:00
Marco
c8f6e7b99e Fix partition selection in speed features for arf overlay frame.
For real-time mode. Move the switch to fixed partition
for is_src_frame_alt_ref so all speeds may use it
if use_altref_onepass is set.

Improves metrics by ~2% for ytlive set at speed 4
(where use_altref_onepass is currently used).

Change-Id: I033240386598c9dbd0364da89ccbcca64bc663ee
2017-09-29 15:02:28 -07:00
Marco
f2c3d0a7a3 Enable use_altref_onepass for speed 4 real-time mode.
Used for VBR mode with lag-in-frames > 0.
On ytlive set at speed 4: ~3% average gain.

Change-Id: I45dad1700bf8be9d8f177815dc062774f6f2f0de
2017-09-29 10:56:14 -07:00
Marco
a2ef180dd0 Set rc->high_source_sad = 0 before scene detection.
Only has effect when sf->use_altref_onepass is enabled,
as in that case scene detection is skipped for non-show frame
and so high_source_sad does not get reset to 0.

No change in metrics or speed.

Change-Id: I421f066d239341449c18826089e1810b9fc5967f
2017-09-28 10:49:45 -07:00
Marco Paniconi
3b8cc214ef Merge "vp9: Modification to adapt the ARF usage for 1 pass vbr" 2017-09-28 16:52:28 +00:00
Marco
03e8f13337 vp9: Modification to adapt the ARF usage for 1 pass vbr
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-09-28 09:10:30 -07:00
Marco
c493ea1a6b Add use_svc condition to the scene detection in 1 pass.
Scene detection is not currently used in SVC 1 pass code.
Speedup of ~0.4%.

Change-Id: I0ab769300919de710cd2da1402014fa3f22a1f86
2017-09-27 14:51:46 -07:00
Marco Paniconi
8d438dc313 Revert "Remove the speed condition on scene detection in 1 pass code."
This reverts commit 535b7b915a.

This is actually used in CBR to reset the rate control if high source sad is detected.

Original change's description:
> Remove the speed condition on scene detection in 1 pass code.
> 
> Scene detection is used for VBR mode and for screen_content mode.
> 
> It was also enabled for CBR mode via the speed condition,
> but currently the analysis in the scene detection is not used
> in CRB mode (similar computations are done locally at superblock level
> when the source_sad feature is enabled).
> 
> For 1 pass code.
> No change in behavior. Small speed gain, ~0.5%.
> 
> Change-Id: I59991d7ef2af320bea7af4b907596e057affa42f

TBR=marpan@google.com,builds@webmproject.org,jianj@google.com

Change-Id: Ib4e6b02047f75632503e7b0fc870af97fa9291c3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
2017-09-27 19:42:48 +00:00
Marco
535b7b915a Remove the speed condition on scene detection in 1 pass code.
Scene detection is used for VBR mode and for screen_content mode.

It was also enabled for CBR mode via the speed condition,
but currently the analysis in the scene detection is not used
in CRB mode (similar computations are done locally at superblock level
when the source_sad feature is enabled).

For 1 pass code.
No change in behavior. Small speed gain, ~0.5%.

Change-Id: I59991d7ef2af320bea7af4b907596e057affa42f
2017-09-27 10:32:54 -07:00
Marco
819c5b365d Remove the speed condition in setting compute_source_sad.
The speed condition is not needed, feature can used for any
speed in 1 pass code.

Change-Id: I878ef3f63a075302eda48c0343fa243c80aab9ba
2017-09-26 15:48:34 -07:00