Jerome Jiang [Mon, 29 Jan 2018 18:14:40 +0000 (10:14 -0800)]
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.
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
paulwilkins [Wed, 31 Jan 2018 16:42:37 +0000 (16:42 +0000)]
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.
Marco [Mon, 29 Jan 2018 18:14:40 +0000 (10:14 -0800)]
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.
paulwilkins [Wed, 7 Feb 2018 15:05:20 +0000 (15:05 +0000)]
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.
paulwilkins [Tue, 6 Feb 2018 13:54:25 +0000 (13:54 +0000)]
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.
Jerome Jiang [Thu, 25 Jan 2018 19:36:53 +0000 (11:36 -0800)]
Fix issue for 0 target bitrate in multi-res build.
For encoding with --enable-multi-res-encoding, with 1 layer, when the
target bitrate is set 0, under these conditions null pointer
will be de-referenced. Fix is to check
cpi->oxcf.mr_total_resolutions > 1. Also added NULL pointer check.
This issue causes crash for asan build in chromium clusterfuzz.
Marco [Wed, 31 Jan 2018 23:15:40 +0000 (15:15 -0800)]
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.
Marco [Wed, 31 Jan 2018 21:33:27 +0000 (13:33 -0800)]
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):.
paulwilkins [Mon, 15 Jan 2018 12:00:01 +0000 (12:00 +0000)]
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.
Marco Paniconi [Wed, 31 Jan 2018 16:56:04 +0000 (16:56 +0000)]
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.
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
Johann [Tue, 30 Jan 2018 19:12:08 +0000 (11:12 -0800)]
vp8 bool: verify buffer size
In the process of fixing a ubsan warning:
commit 738b829b8cdf079a5fa48c74a28a177c9567d212
Fix incorrect size reading
the inferred check of start < end was removed. This causes fuzzed files
to get a little further and segfault in vp8dx_start_decode.
Johann [Mon, 29 Jan 2018 19:57:00 +0000 (11:57 -0800)]
Merge remote-tracking branch 'origin/mandarinduck' into HEAD
The following changes were not carried back from the release branch:
commit f87a4594fbd0b19071a2befebf52d3f5fabd1a9e
Revert "Add frame width & height to frame pkt. Add test."
Marco [Fri, 26 Jan 2018 03:00:31 +0000 (19:00 -0800)]
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.
Marco [Thu, 25 Jan 2018 01:12:43 +0000 (17:12 -0800)]
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.
Marco [Wed, 24 Jan 2018 04:03:19 +0000 (20:03 -0800)]
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.
Shiyou Yin [Tue, 23 Jan 2018 03:33:25 +0000 (11:33 +0800)]
vp8: [loongson] fix bug of type conflict.
In commit 577d4fa79, int8_t was used to replace char. This will result in a
compilation error, for int8_t was typedefined to signed char, but not char.
Marco [Tue, 16 Jan 2018 19:37:40 +0000 (11:37 -0800)]
vp8: Fix to multi-res-encoder for skipping streams.
For the vp8 simulcast/multi-res-encoder:
Add flags to keep track of the disabling/skipping of
streams for the multi-res-encoder. And if the lower spatial
stream is skipped for a given stream, disable the motion
vector reuse for that stream.
Also remove the condition of forcing same frame type
across all streams.
This fix allows for the skipping/disabling of the base
or middle layer streams.
Without this applications cannot use the vpx_codec_control macro
for VP9_SET_SKIP_LOOP_FILTER. The tests only cover the underscored
version vpx_codec_control_().
Without this applications cannot use the vpx_codec_control macro
for VP9_SET_SKIP_LOOP_FILTER. The tests only cover the underscored
version vpx_codec_control_().
paulwilkins [Thu, 4 Jan 2018 16:02:42 +0000 (16:02 +0000)]
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%