James Zern [Sat, 17 Mar 2018 00:47:56 +0000 (17:47 -0700)]
CopyFrameTest: reduce max size for 32-bit targets
avoids potential OOM when allocating 3 buffers for 16383x16383; 3840 is
used as a replacement
this test was missed in: 215bddf32 vpx_scale_test: reduce max size for 32-bit targets
Marco Paniconi [Wed, 14 Mar 2018 17:03:31 +0000 (10:03 -0700)]
vp9-svc: Frame dropper for SVC.
If a given spatial layer decides to drop, due to the
buffer/overshoot conditions for that layer, then drop
that current spatial layer and all spatial layers above.
In the current implementation the svc frame counter
(and hence the pattern for the non-flexible SVC case)
are updated on frame drops.
Also add last spatial layer encoded to the pkt.
This is useful for RTC applications that enable
frame dropping for SVC.
Update to the SVC datarate tests:
enabled frame dropper on all SVC datarate tests, and
made a fix to properly set the temporal_layer_id, which
works now even on frame drops.
Reason for revert:
this should be investigated further to ensure the memset is really
necessary outside of the static analysis pass.
Original change's description:
> vp9_loopfilter.c: zero lfl_uv
>
> The initialization depends on cm and mi_row which static
> analysis does not approve of.
>
> Clears a static analysis warning:
> warning: The right operand of '+' is a garbage value
> const loop_filter_thresh *lfi = lfthr + *lfl;
>
> Change-Id: I8c863ced2b1e9a7e10103b7281098f20941a6ca2
Marco Paniconi [Thu, 15 Mar 2018 00:00:27 +0000 (17:00 -0700)]
vp9-svc: Bugfix to dyanmic enabling/disabling of layers.
Fix a bug when middle and top spatial layer are skip encoded
(disabled) and then re-enabled again, during the sequence.
Issue is that pending_frame_count in the packing may
be incremented on middle layer, even though that layer is skipped
(not encoded and hence zero size). Fix is to add size check.
Clears static analysis warnings similar to the low bitdepth version:
commit c4367b9b51782969d3b37ead6694d19ef9bfb58c
Author: James Zern <jzern@google.com>
Date: Wed Mar 18 14:34:30 2015 -0700
vp9_resize_plane: quiet some static analysis warnings
Johann [Wed, 14 Mar 2018 20:25:05 +0000 (13:25 -0700)]
vp8 rdopt.c: zero rd.[rate_uv|distortion_uv]
These values are not consistently set before calling update_best_mode.
In vp9_rdopt.c they are individual values instead of a struct and are
zero'd at declaration.
Clears a static analysis warning:
warning: The right operand of '-' is a garbage value
RDCOST(x->rdmult, x->rddiv, (rd->rate2 - rd->rate_uv - other_cost),
warning: The right operand of '-' is a garbage value
(rd->distortion2 - rd->distortion_uv));
Johann [Wed, 14 Mar 2018 20:10:08 +0000 (13:10 -0700)]
vp8 mfqe: zero map[]
The loop appears to set map[i] with the intention of running
the 'j' loop up to that point. However, without zero'ing map[]
first the behavior is unpredictable.
Fixes a static analysis warning:
warning: Branch condition evaluates to a garbage value
for (j = 0; j < 4 && map[j]; ++j) {
Johann [Wed, 14 Mar 2018 01:31:26 +0000 (18:31 -0700)]
spatial svc: set window_size to 15
Static analysis does not recognize that output_rc_stat guards
the usage of window_size. Clears this warning:
The right operand of '>' is a garbage value
if (frame_cnt > (unsigned int)rc.window_size) {
set_rate_control_stats sets window_size to 15. Zeroing it
just introduces another static analysis warning.
Johann [Wed, 14 Mar 2018 01:22:40 +0000 (18:22 -0700)]
spatial svc: zero sizes
This should be taken care of by parse_superframe_index but
the static analysis is not recognizing it because it depends
on 'marker' which is read from the bitstream.
Clears a static analysis warning:
The right operand of '*' is a garbage value
rc.layer_encoding_bitrate[layer] += 8.0 * sizes[sl];
Marco Paniconi [Thu, 1 Mar 2018 17:45:11 +0000 (09:45 -0800)]
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,...).
paulwilkins [Wed, 21 Feb 2018 11:18:09 +0000 (11:18 +0000)]
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)
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.
Kyle Siefring [Mon, 5 Feb 2018 05:15:29 +0000 (00:15 -0500)]
Fold adds in 16->32-bit converts in SSE2/AVX2 fDCT
Changes in the function size in bytes (in lieu of performance metrics)
Before After Diff
vpx_fdct32x32_avx2 29564 -> 28334 -1230
vpx_fdct32x32_sse2 38053 -> 36309 -1744
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