Jingning Han [Mon, 10 Sep 2018 18:55:10 +0000 (11:55 -0700)]
Rework two_pass_first_group_inter()
This function is used to in part decide if to trigger recode loop
for the first normal P frame in a GOP. Rework its design logic to
support the GOP with multi-layer ARF. Allow recode when there is
a transition from ARF/OVERLAY/USE_BUF to normal P frame.
The overall coding performance for multi-ARF gets slightly better
(less than 0.1% for show_existing_frame case). Tested on a few
clips, the encoding speed remains similar too. This change primarily
serves to help integration of multi-layer ARF and dual-ARF systems.
Jingning Han [Fri, 7 Sep 2018 23:37:42 +0000 (16:37 -0700)]
Separate frame context index for GOP layers
Use separate frame context index to code frames at different layers.
The maximum index cap is set as 3. This improves the compression
performance of multi-layer ARF by 0.15% across the test sets.
Jingning Han [Fri, 7 Sep 2018 17:25:07 +0000 (10:25 -0700)]
Fork auto-alt-ref control
Temporarily fork the auto-alt-ref control meaning. When it is set
to be 1, use single layer ARF as baseline. The value 2 would enable
dual ARF system. Any number above it would trigger automatic multi-
layer ARFs.
We would gradually refactor and integrate dual ARF and multi-layer
ARF systems next, and eventually make auto-alt-ref directly control
the layer depth.
Jingning Han [Fri, 7 Sep 2018 17:20:56 +0000 (10:20 -0700)]
Extend auto-alt-ref parameter range
Extend the upper limit from 2 (dual ARFs) to maximum ARF layers.
This would later allow --auto-alt-ref to directly control the
ARF layer depth later on.
Jingning Han [Fri, 31 Aug 2018 22:54:10 +0000 (15:54 -0700)]
Adaptive ARF factor decision
Re-count the factors to decide bit boost factor for the
intermediate layer ARFs. Make the gfu_boost factor assigned to
each ARF adapt to its local factors.
This and the recursive change 5bfe9eb together improves the
multi-layer ARF compression performance:
Jingning Han [Thu, 30 Aug 2018 04:30:35 +0000 (21:30 -0700)]
Recursive rate allocation for multi-layer ARF coding
Recursively calculate the rate boost for the ARF frames at the
given layer depth from the remaining available bit resource after
the prior layer ARFs consumption.
Jingning Han [Tue, 28 Aug 2018 21:08:02 +0000 (14:08 -0700)]
Enable adaptive rate allocation for multi-layer ARFs
Increase the bit allocation for the intermediate layer ARFs. The
current strategy assigns higher offset to the lower layer ARFs.
The needed budget is borrowed from the base layer ARF allocation.
Jingning Han [Tue, 28 Aug 2018 19:43:34 +0000 (12:43 -0700)]
Increase encoder buffer for multi-layer ARFs
When multi-layer ARF mode is enabled, increase the encoder buffer
to account for the situation where several ARFs are coded together
in a frame packet.
Paul Wilkins [Mon, 3 Sep 2018 15:48:02 +0000 (16:48 +0100)]
Fix short first kf bug.
This change is in response to quality issue in b/112953058
The quality regression observed is a result of a bug that manifested
because of a very short key frame group at the start of a chunk.
The group was so short that it was less than the minimum allowed
length of an ARF group, so the initial group was coded as a GF only
group. However, group length was not set correctly and the result
was a frame coded with a target of 0 bits.
This causes two problems:
Firstly one very poor frame that caused the issue to be raised.
Secondly that one frame obviously overshoots its 0 target very heavily
and this has the effect moving the needle significantly in terms of the
adaptive rate control (specifically the estimate of bits per macro block
used to estimate the active Q range). Consequently there is undershoot
for most of the rest of the chunk and the overall rate ends up much lower
than the target (14Mb/s vs a target of 22Mb/s). (The sharp drop in the
overall rate is also noted in the issue.
Paul Wilkins [Mon, 3 Sep 2018 15:12:22 +0000 (16:12 +0100)]
Revert "Revert "Prevent double application of min rate in two pass.""
This rate control bug in the original patch is not the underlying cause
of the quality regression but simply unmasked a problem which stems
from applying 0 bits to the last frame in a short KF group at the start
of a chunk.
Marco Paniconi [Mon, 3 Sep 2018 05:17:32 +0000 (22:17 -0700)]
vp9-svc: Fix condition for pattern constraints
For fixed/non-flexible SVC mode: on non-key spatial
enhancement layers modify constraint on the inter-layer
prediction to include the first_spatial_layer_to_encode.
Marco Paniconi [Fri, 31 Aug 2018 22:42:19 +0000 (15:42 -0700)]
vp9-svc: Add first_spatial_layer_to_encode per superframe
VP9E_SET_SVC_LAYER_ID sets the first spatial layer to
encoder per superframe, so add this parameter to svc encoder.
This is needed, for example, to properly set is_key_frame for
spatial layers when base spatial layer is skipped encoded.
Hui Su [Tue, 17 Jul 2018 05:05:19 +0000 (22:05 -0700)]
ML based rectangular partition search pruning
Add a ML model to predict if rectangular partition search can be skipped
without much coding loss. This model is enabled for speed 0 low bitdepth
only.
Johann [Thu, 30 Aug 2018 21:07:02 +0000 (14:07 -0700)]
silence c++ abi warning
Linking c++ libraries built with gcc 6 and gcc 7 on arm
generates some warnings because of incompatibilities between those
compilers:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
libvpx does not generate a c++ library. C++ is only used for examples and tests.
Jingning Han [Mon, 27 Aug 2018 22:22:24 +0000 (15:22 -0700)]
Rework enc/dec mismatch detection
The previous enc/dec mismatch detection assumes the previously
reconstructed frame would always stay at frame buffer pool index
at 0. It could hence cause certain delay in enc/dec mismatch
detection when the immediate reconstruction frame is not yet
propagated to index 0 in the buffer map pool.
This change always keeps the latest decoded show frame buffer
index and directly gets the reconstructed frame from encoder and
decoder buffer pools to check for mismatch.
Reason for revert: it causes visual quality drop as described in b/112953058.
Original change's description:
> 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
Jingning Han [Wed, 22 Aug 2018 17:23:53 +0000 (10:23 -0700)]
Skip update prev_mi frame in show_existing_frame mode
When the current frame is coded by directly using a reference
frame in buffer, no need to update the prev_mi frame information
for next frame encoding control.
Hui Su [Wed, 22 Aug 2018 05:02:42 +0000 (22:02 -0700)]
Rework the ref_frame_skip_mask feature in RDO
Previously we often skip all compound inter prediction modes,
causing large coding loss. This patch modifies how we set the
ref_frame_skip_mask so that compound modes are considered in RDO.