Commit Graph

6920 Commits

Author SHA1 Message Date
Marco Paniconi
312745cac4 vp9-svc: Update layer frame counters when layer is skipped.
When an enhancement spatial layer is skipped, we should check
for updating the layer frame counters.

Change-Id: Ib79d0955c62fb465f59ef2f9ac45240ae2614d7b
2018-03-12 12:21:10 -07:00
Marco Paniconi
3223a3f892 vp9-SVC: Fix to choose_partition when LAST ref is NULL.
This causes assert to trigger in choose_partitioning().
This can happen in some cases when enhancement layers
are enabled midway during the stream.

Change-Id: I69c3c8b4b1e3f1c7d8d7294d633ca5ddca148e8b
2018-03-12 09:13:25 -07:00
Paul Wilkins
7987f35391 Merge "Change to KF frame boost calculation." 2018-03-08 13:34:15 +00:00
Marco Paniconi
5ac63d15dc vp9-svc: Disable partition_reuse unless 2x2 scale.
For SVC, if any of the layer scale ratios are not
2x2, then disable the partiton_reuse, which assumes
2x2 scaling between layers.

Change-Id: I8b3163de0826052bbb1bfe03554a074c89510558
2018-03-02 10:56:16 -08:00
Marco Paniconi
4d8958d8dd vp9-svc: Fix to downsampling filter phase_shift.
Set phase_shift = 0 if the scale factors are
above 3/4. Removes artifact for scale factors
close to 1.

phase_shift = 8 is to get an averaging filter
(decimated pixel aligns to 8/16, midway between source pixels),
and only makes sense for scale factors multiples of
2 (1/2, 1/4,...).

Removes artifact for high scaling ratios.

Change-Id: Id0a85869d6c6156dda0032c697ded2de78fad6bd
2018-03-02 08:55:18 -08:00
paulwilkins
29fbddec83 Change to KF frame boost calculation.
This change is targeted mainly at higher resolutions where typically
the average error per MB is much smaller.  hence this patch replaces
a fixed error per MB factor with a tiered value.

It also adds in a fixed offset value that acts as a minimum return score.

Note also minor fix to debug stats output.

The results are overall beneficial (-ve) on our test sets, most notably for
higher definition formats (see below - overall psnr, ssim, psnr hvs)

low res:    0.184	-0.262	-0.166
mid res:   0.094	  0.075	  0.049
hd res:    -0.752	-0.300	-0.800
NF 2K:    -0.353	 1.095	-0.302
NF 4K:    -1.245	-0.578	-1.205

The most notable negative case is pierseaside 2K which appears to be worse by
8-10% (which has a big impact on the overall gain for the NF 2K set). Closer
inspection reveals that the drop does not relate to the key frame boost
per se as in both cases the key frame substantially undershoots its target. Rather
this is a side effect relating to the initial Q range allowed for the key frame and
a poor initial complexity estimate. This will hopefully be improved in a later
patch.

Change-Id: I4773ebe554782f4024c047c3c392c763a3fe843b
2018-02-28 20:56:53 +00:00
Jerome Jiang
11b55a0614 Merge "Reland "Add ROI support for VP9."" 2018-02-09 19:01:52 +00:00
Jerome Jiang
46adbc4af8 Reland "Add ROI support for VP9."
Extended ROI struct suitable for VP9.
ROI input from user is passed into internal struct and applied on every frame
(except key frame).

Enabled usage of all 4 VP9 segment features (delta_qp, delta_lf, skip,
ref_frame) via the ROI map input.
Made changes to nonrd_pickmode for the ref_frame feature.

Only works for realtime speed >= 5.
AQ_MODE needs to be turned off for ROI to take effect.

Change example in the sample encoder: vpx_temporal_svc_encoder.c to be suitable
for VP9.
Add datarate test.

Bump up ABI version.

BUG=webm:1470

Change-Id: I663b8c89862328646f4cc6119752b66efc5dc9ac
2018-02-09 10:55:46 -08:00
Jerome Jiang
efaaf387fc Merge "Revert "Add ROI support for VP9."" 2018-02-09 18:54:55 +00:00
Jerome Jiang
62b013abe8 Revert "Add ROI support for VP9."
This reverts commit 4e5b4b5848.

Reason for revert: Commit message inaccurate.

Original change's description:
> Add ROI support for VP9.
> 
> Extended ROI struct suitable for VP9.
> ROI input from user is passed into internal struct and applied on every frame
> (except key frame).
> 
> Enabled usage of all 4 VP9 segment features (delta_qp, delta_lf, skip,
> ref_frame) via the ROI map input.
> Made changes to nonrd_pickmode for the ref_frame feature.
> 
> Only works for realtime speed >= 5.
> AQ_MODE needs to be turned off for ROI to take effect.
> 
> Change example in the sample encoder: vpx_temporal_svc_encoder.c to be suitable
> for VP9.
> Add datarate test.
> 
> Bump up ABI version.
> 
> BUG=webm:1470
> 
> Change-Id: I7e0cf6890649adb98a5fda2efb6ae1fa511c7fc9

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

Change-Id: I000dbd81e0c67cb8a0dcde4013ee9bf7afb038f0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webm:1470
2018-02-09 18:53:54 +00:00
Jerome Jiang
c930ea7dcd Merge "Add ROI support for VP9." 2018-02-09 16:58:55 +00:00
paulwilkins
2fa333c2ae Improved coding on slide show content.
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
2018-02-09 15:13:25 +00:00
Marco
4e5b4b5848 Add ROI support for VP9.
Extended ROI struct suitable for VP9.
ROI input from user is passed into internal struct and applied on every frame
(except key frame).

Enabled usage of all 4 VP9 segment features (delta_qp, delta_lf, skip,
ref_frame) via the ROI map input.
Made changes to nonrd_pickmode for the ref_frame feature.

Only works for realtime speed >= 5.
AQ_MODE needs to be turned off for ROI to take effect.

Change example in the sample encoder: vpx_temporal_svc_encoder.c to be suitable
for VP9.
Add datarate test.

Bump up ABI version.

BUG=webm:1470

Change-Id: I7e0cf6890649adb98a5fda2efb6ae1fa511c7fc9
2018-02-08 16:30:56 -08:00
paulwilkins
b78dad3ffa Adjust MAXRATE_1080P.
This value was originally set in response to requests from the hardware
team before levels were properly defined for VP9.

Even if a level is not specified for an encode, it imposes a maximum
frame size for videos of dimensions <= 1080P.  For larger formats the
limit was set at 250 bits per MB.

This patch modifies the limit to be more in line with the requirements
specified for level 4 (max rate for a 4 frame group of 16 Mbits).  If a lower
level is specified at encode time and this mandates a smaller maximum frame
size then the level requirement will still take precedence.

Increasing this value allows for some slide shows or very low motion clips
to code a better quality key frame.

Change-Id: Ic08e0e09c8a918077152190c59732b9a1c049787
2018-02-08 12:31:09 +00:00
Paul Wilkins
1acc25f11b Merge "Fix file input pointer bug in allocate_gf_group_bits()." 2018-02-08 10:57:44 +00:00
paulwilkins
c104f4cbdc Fix file input pointer bug in allocate_gf_group_bits().
The stats input pointer, when passed in, already points to the
frame after the golden frame so should not be advanced here.

This fix has a small mostly positive effect on results in our test sets
(tested using corpus vbr settings) and gives a gain of almost 0.5%
in overall psnr (plus slightly smaller gains on other metrics) for the
4K set.

The bug also caused a crash in calculate_group_score() in another
patch which allows coding of slides in a slide show as a single
long KF group without ARFs or GFs.

Change-Id: I57a3a24baf442ce55dbc91fba05e056697c63a6f
2018-02-06 14:02:33 +00:00
Linfeng Zhang
82e9c30334 Update tx_type switch code in idct
Change-Id: Ia244bfd4b4eb9d703653792bc4f64c6f5358ae19
2018-02-05 13:42:26 -08:00
Paul Wilkins
79c14b83e9 Merge "Further change to code detecting slide transitions." 2018-02-01 10:21:38 +00:00
Marco
cb16652598 vp9-svc: Add condition on allocation for scaled_temp.
scaled_temp frame is used as an intermediate buffer for
2 stage down-sampling: two stages of 1/2 down-sampling
for a target of 1/4x1/4. This is used in 3 layer SVC
to avoid duplicate frame downsampling (on middle layer).

As this allocation is only needed/used when the
number_spatial_layers > 2, add this condition to avoid
unneeded allocation for 1 and 2 spatial SVC.

Change-Id: If342466644f685c1ea3ca5344b581793e5136c09
2018-01-31 15:19:27 -08:00
Marco
2c950e131c vp9-svc: Fix to initialize downsampling filters.
For 3 spatial layers with 1/2 downsampling, the
downsampling filter for the middle layer was not
set for the very first frame, so it was defaulting
to the subsample filter (no averaging/phase = 0).

Its not set due to the two stage scaling that is
done for 1/4 on base layer, during which the intermediate
1/2 result is saved for the middle layer.

Fix for now is to set the default downsampling filter
to Bilinear (averaging/non-zero phase) for all layers on
init (vp9_init_layer_context):.

Change-Id: Ic7407810b34c621e7e7420682508d45478bdffcf
2018-01-31 13:49:16 -08:00
paulwilkins
41d3331d42 Further change to code detecting slide transitions.
Eliminate false positives in previous patch.

The previous patch did a good job of detecting slide transitions but
in discussions a number of situations were identified that might trigger
harmful false positives. This risk seems to be born out by some testing
on a wider YT set done by yclin@.

This patch adds an additional clause that requires that the best case
inter and intra error for the frame are very similar,meaning it is almost
as easy to code a key frame as an inter frame. This will certainly prevent
the false positive conditions that Jim and I discussed and even if one
does occur it should not be very damaging.

The down side is that this clause may mean that we still miss some
real slide transitions, especially if the images are small and similar.  If this
proves to be the case then some further adjustment of the threshold may be
required. However, in the specific problem sample provided we do  trap every
transition correctly.

Change-Id: I7e5e79e52dc09bc47917565bf00cc44e5cddd44c
2018-01-31 17:44:46 +00:00
Marco Paniconi
efa786d464 vp9 svc: Make top layer non-ref: for 2 TL case
Only affects 2 temporal layer case.
Modified the flags for 2 temporal layers to make
top layer (top spatial, top temporal) a non-reference
frame, conistent with the 3 TL case.

Add mismatch check to the datarate test of changing
svc pattern on the fly, which is test for 2 temporal
layers.

This re-applies the change: 254e2f5501,
that was reverted in: 658eb1d675.

Change-Id: Ib5fd4a7a0312c0c05329ae75baac480af34b4694
2018-01-31 09:17:43 -08:00
Marco Paniconi
7edd1a6cea Revert "vp9 svc: fix to make top layer frame non-ref"
This reverts commit 254e2f5501.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> vp9 svc: fix to make top layer frame non-ref
> 
> Add mismatch check to the datarate test of changing svc pattern on the
> fly.
> 
> Change-Id: I6a878736de44e6a40c077ed6430aabd7fadabdd9

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

Change-Id: Ibcb600438098f8dc380fe7e1de90cb81fc367468
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
2018-01-31 16:49:16 +00:00
Jerome Jiang
254e2f5501 vp9 svc: fix to make top layer frame non-ref
Add mismatch check to the datarate test of changing svc pattern on the
fly.

Change-Id: I6a878736de44e6a40c077ed6430aabd7fadabdd9
2018-01-29 18:38:46 -08:00
Jerome Jiang
3fa713caee Merge "vp9 svc: Update temporal_layering_mode in config change." 2018-01-26 22:45:39 +00:00
Jerome Jiang
cc91abb325 vp9 svc: Update temporal_layering_mode in config change.
temporal_layering_mode can be changed on the fly.

BUG=webm:1488

Change-Id: I223fd4085184e41878ddf0f9244d2e3d07636ae3
2018-01-26 13:38:04 -08:00
Marco
a9bbff1049 vp9-svc: Adjust logic on intra mode search.
For SVC, on spatial enhancement layer, intra
search was disabled unless best reference frame
is golden (i.e., spatial/inter-layer prediction),
except for some other conditions (lower layer is key
or golden is not an allowed reference).

Fix is to add the base temporal layer condition,
so intra search will not be force-disabled for base
temporal layer frames.

This improves metrics (-1-2%) for SVC 3 and 2 layer config.
Some small encode time is expected, but since condition
only affect base temporal layers (i.e., every 4 frames
for 3 layers), increase is small.

Change-Id: I10b824faef99560dfdeeb02ba8bf8e3e1eea6255
2018-01-25 19:11:42 -08:00
Marco
067457339b vp9-svc: Add QP dependency to thresh_svc_skip_golden.
In nonrd-pickmode: the golden/spatial reference for inter-layer
prediction may be skipped in the mode testing. Add QP dependency
to reduce the threshold for skipping (i.e., check it more often)
at high QP, if the lower layer was encoded at lower QP relative
to the current layer.

At high QP, a better quality lower resolution is more likely to
provide good spatial (inter-layer) prediction.

avgPSNR/SSIM metrics up by ~1% (all clips positive gain or neutral).
Some decrease in encode time (~1-2%) expected at lower bitrates,
for 3 layer SVC.

Change-Id: I9ee0f62d4b10d4ebd30165d378ecfa4399ae5ef1
2018-01-25 09:00:58 -08:00
Marco Paniconi
3b85a5beb7 Merge "vp9-svc: Re-adjust some aq-mode=3 control parameters." 2018-01-24 20:29:10 +00:00
Scott LaVarnway
b9e44842fc Merge "vp9_quantize_fp_avx2()" 2018-01-24 13:58:08 +00:00
Marco
7c69136494 vp9-svc: Re-adjust some aq-mode=3 control parameters.
Remove an adjustment to two cyclic refresh (aq-mode= 3)
parameters for SVC. The adjustment was to reduce the
delta-qp on second segment, and reduce the motion threshold.
This was done early on in the SVC encoder development,
in the latest codebase removing this adjustment yields
some improvements in metrics.

The avgPSNR/SSIM metrics increase on average by ~1%
(most clip positive gain), for 3 and 2 layer SVC.

Change-Id: I7a4d5114f16b2a1df383dbe6b3fe02940e29e6cc
2018-01-23 20:14:00 -08:00
Johann Koenig
3761254119 Merge changes from topic "clang-format"
* changes:
  clang-format v5.0.0 vp9/
  remove spurious comments
  clang-format v5.0.0 vp8/
  clang-format v5.0.0 vpx_dsp/
  clang-format v5.0.0 mem_ops.h
  clang-format v5.0.0 vpx_util/vpx_atomic.h
  clang-format v5.0.0 y4minput.c
  clang-format v5.0.0 vpxenc.c
  clang-format v5.0.0 examples/
  clang-format v5.0.0 test/
2018-01-22 19:38:42 +00:00
Scott LaVarnway
c7449b482c vp9_quantize_fp_avx2()
Started from vp9_quantize_fp_sse2 and tweaked to use avx2.

Change-Id: Ic2da50cc9d73896c7ef2f3cd3db5b1c5d7795b8b
2018-01-18 13:33:30 -08:00
Johann
281f68a81f clang-format v5.0.0 vp9/
Remove trailing commas to keep multiple elements on one line.

Add blank lines to prevent comments from being treated as blocks.

clang-format guards for struct with a comment in the middle.

Change-Id: I3bcb8313ae8aaf69179249a13b4087b1272cdbc0
2018-01-18 12:37:58 -08:00
Paul Wilkins
f915e6d4af Merge "Add zoom break out for kf boost loop." 2018-01-12 18:45:28 +00:00
Paul Wilkins
733820c509 Merge "Fix kf detection in some slide shows." 2018-01-12 18:45:13 +00:00
Marco
f8639b1554 vp9: Skip encoding of enhancement layers on the fly.
For SVC: if an enhancement layer (spatial_layer > 0)
has 0 bandwidth, skip/drop the encoding of the layer.
This allows the application to dynamically disable
higher layers for SVC.

Add flag to signal the skip encoding, this is needed
to modify the packing of the superframe when the top
layer is skipped/dropped.

Also moved some updates (current_video_frame counter and
the last_avg_frame_bandwidth) to the postencode_update_drop_frame().

Added datarate unittest for dynamically going from 3 to 2
and then back to 3 spatial layers.

Change-Id: Idaccdb4aca25ba1d822ed1b4219f94e2e8640d43
2018-01-11 10:38:30 -08:00
Vlad Tsyrklevich
1633786bfb [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 some function pointer casts that I missed in my last
CL https://crrev.com/c/780144.

BUG=chromium:776905

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

Change-Id: I1c7adbdfffa4fe0b62e993bfb31d06e64b022d66
2018-01-10 16:38:26 -08:00
Paul Wilkins
bbdbee429f Merge "Fix bug in use of zoom metric as part of arf breakout." 2018-01-10 17:33:00 +00:00
paulwilkins
32f86ce276 Add zoom break out for kf boost loop.
Adds a breakout threshold to key frame boost loop.

This reduces the boost somewhat in cases where there is a
significant zoom component. In tests most clips no effect
but a sizable gain for some clips like station.

Change-Id: I8b7a4d57f7ce5f4e3faab3f5688f7e4d61679b9a
2018-01-10 17:26:32 +00:00
paulwilkins
bb4052b873 Fix kf detection in some slide shows.
This fix improves detection of key frames in slide shows.

In particular it helps if the slides are pictures of varying formats
as in a sample provided by yclin@.

This change does not impact any of the clips in our standard tests
but for the example slide show test clip helped global psnr by
several db and resolved a serious visual quality issue.

Change-Id: Iaeeeed55dc0bb50aeacd4996ed660ced06374603
2018-01-10 15:07:38 +00:00
Marco Paniconi
bed28a55f5 Merge "vp9-svc: Use eightap_smooth for downsampling at low resol." 2018-01-05 19:01:31 +00:00
Marco
321f295632 vp9-svc: Use eightap_smooth for downsampling at low resol.
Switch from bilinear to eighttap_smooth for frame-level
downsampling at low resolutions (<= 320x240).

avgPSNR/SSIM metrics increase from ~0.5-2% (all clips positive gain),
for 2 and 3 spatial layer SVC, with 3 temporal layers.
Small/negligible increase in encoding time (< 1%).

Change-Id: I758472fc4fddd51d87f13c9d1a1cd4986ef5d41f
2018-01-05 10:17:08 -08:00
paulwilkins
0226ce79e9 Fix bug in use of zoom metric as part of arf breakout.
The in/out (or zoom metrics) in accumulate_frame_motion_stats()
are in effect a % of the blocks that have a motion vector pointing
either towards or away from the center. As such they are already
normalized in terms of image size and the thresholds against which
these are tested should be image size independent.

In practice a zoom either in or out is an indicator for a shorter group
length so the abs value is more important as a breakout clause.

This patch fixes the threshold test. Clips without noticeable zoom show
no effect but some  with strong zooms such as "station" show a big
gain (5-10%). Average psnr-hvs gain on hdres set was 0.292%

Change-Id: I4f97a72b0e273e4e844ade15285749c32cd81c1c
2018-01-05 13:19:35 +00:00
Marco
55db4f033f vp9: Increase convergence speed of noise estimation.
Increase the recursive average factor from 15/16 to 3/4
to make the noise estimation respond faster.

Small/neglible change on low noise content, but better
denoising for noisy content.
Also encoder speedup of ~2-3% observed on some noisy clips.

Change-Id: I9dd02fe961ca24b411fe4c2732f814bf1e9a7f9f
2018-01-04 14:29:27 -08:00
James Zern
84a7263d4c vp9_quantize_ssse3_x86_64: fix out of bounds write
eob is a pointer to a uint16_t. previously the code would store 64-bits
causing a crash or test failure with the right stack layout.

Change-Id: Ibd653baf323db114f2444951b9d8b00c596bf15a
2017-12-21 16:53:14 -05:00
Marco
a2127236ae vp9: Reset buffer level on large bitrate changes.
For a large change in the target avg_frame_bandwidth,
via the update in change_config()), reset the buffer_level
to optimal_level.

This fix prevents possible frame drops, where for example,
encoder suddenly goes from lower to higher bitrate.

Change-Id: I2f844c41d04c01240e85f574e59d2b9075c7eb6d
2017-12-19 09:57:21 -08:00
Johann
6746ba6d01 fix typo in boilerplate
The extra 'e' was causing the chromium license check to flag this file.

BUG=chromium:98319

Change-Id: Ic875ba66370298bf998438d14ff5f7e760293706
2017-12-14 11:54:16 -08:00
Marco Paniconi
028429310a Merge "vp9: Reset rc flags on some configuration changes." 2017-12-13 21:03:40 +00:00
Marco
e9ad5d2aee vp9: Cleanup/remove TODO comment.
Change-Id: I2bd43e996909ad688b7e00b81ee19a5fc4df460b
2017-12-13 11:30:09 -08:00