Commit Graph

270 Commits

Author SHA1 Message Date
Debargha Mukherjee
9852643373 Expose params min-gf-interval/max-gf-interval
Adds two new vp9 parameters --min-gf-interval and --max-gf-interval
to enable testing based on frequency of alt-ref frames.

Also adds a unit-test to test enforcement of min-gf-interval.

For both these parameters the default value is 0, which indicates
they are picked by the encoder, based on resolution and framerate
considerations. If they are greater than zero, the specified
parameter is honored.

(Additional note by paulwilkins)
Note that there is a slight oddity in that key frames are also GFs and
considered part of  GF only group. However they are treated as not
being part of an arf group because for arf groups the previous GF is
assumed to be the terminal or overlay frame for the previous group.

(end note)

Change-Id: Ibf0c30b72074b3f71918ab278ccccc02a95a70a0
2015-07-06 12:24:59 -07:00
Marco
1c7b1f9aec Update to dynamic resize logic for 1pass CBR.
Only do the check for resizing if the feature is selected
(i.e., resize_mode = RESIZE_DYNAMIC).

And modify condition for checking to be resize_count >= window,
(since framerate can change).

Change-Id: Idceb4e50956bb965a1492b4993b0dcb393c9be4d
2015-06-25 12:28:43 -07:00
Yaowu Xu
d8428ae35d Fix a msvc compiler warning
Change-Id: Ida8a04370895ed14bd118324ec2577da926e4648
2015-06-19 09:04:29 -07:00
Marco
d77f51ba9e Add dynamic resize logic for 1 pass CBR.
Decision to scale down/up is based on buffer state and average QP
over previous time window. Limit the total amount of down-scaling
to be at most one scale down for now.

Reset certain quantities after resize (buffer level, cyclic refresh,
rate correction factor).

Feature is enable via the setting rc_resize_allowed = 1.

Change-Id: I9b1a53024e1e1e953fb8a1e1f75d21d160280dc7
2015-06-18 17:13:37 -07:00
Marco
c139b81a13 Vidyo patch: Rate control for SVC, 1 pass CBR mode.
-Make Rate control work for SVC 1 pass CBR mode.
-Added temporal layering mode.
-Fixed bug in non-rd variance partition.
-Modified/updated the sample encoders (vp9_spatial_svc_encoder, vpx_temporal_svc_encoder).
-Added datarate unittest(s) for 1 pass CBR SVC.

Change-Id: Ie94b1b68a56ea1267b5087c625e5df04def2ee48
2015-06-02 07:54:13 -07:00
paulwilkins
883fdd45cf Fast feedback of bits on undershoot.
This patch provides a partial rapid feedback of bits
resulting from extreme undershoot.

Some  improvement on some problem animated material
but in its current form only a small impact on the metrics results
of our standard test sets.

Change-Id: Ie03036ea8123bc2553437cb8c8c9e7a9fc5dac5d
2015-05-20 16:47:34 +01:00
paulwilkins
ade9693a30 Fix issues with mixed ARF and GF groups.
This patch addresses two issues that can occur when the
encoder chooses to use a mixture of ARF and GF groups.

The first issue relates to a failure to reset the "ARF active" flag
correctly when transitioning from coding ARF groups to coding
GF groups. This caused some golden frames to be  encoded
with an incorrect bit rate target as if they were ARF overlay frames.

The second issue relates to the encoding of a single short GF group
just before a key frame.  Where the last group before a key frame
is an ARF group we expect the final frame before the key frame  to
be an low data rate overlay frame. However, when the last  group
is a GF group, the final frame before the key frame should be a normal
frame with a normal bit allocation. This issue had the potential to cause
a single poorly coded frame just before a key frame. If that key frame
were a forced key frame rather than a real scene cut, this might cause
pulsing.

Change-Id: Idf1eb5eaf63a231495a74de7899236e1ead9fb00
2015-05-20 16:46:44 +01:00
James Zern
18b60af27c vp9: correct some function signatures
silences missing prototype warnings

Change-Id: Idaf68d83d2cb03847f3ee002c4d00c2ac79da604
2015-05-15 10:43:47 -07:00
Johann
1d7ccd5325 Relocate memory operations for common code
With the sad functions, and hopefully the variance functions soon,
moving to the vpx_dsp location, place the defines used in the
reference C code in a common location.

Change-Id: I4c8ce7778eb38a0a3ee674d2f1c488eda01cfeca
2015-05-13 11:41:15 -07:00
Marco
913862be8c Fix rate control issue with layers and aq-mode=3.
When aq-mode=3 is enabled, only for base layer frames should the
qp of the frame incorporate the segment delta-qp.

This was causing more rate mismatch for the enhancement layer frames
when running temporal layers with aq-mode=3 on.

Change-Id: I1c5e69d1ef8a51188af8696753c17fd8f67699b3
2015-05-11 10:04:18 -07:00
paulwilkins
e0786c280e Adjust ARF min and max interval.
Previously limit on max interval  set to 0.5 seconds.
Though this helped some low frame rate material it
appears to be a bit too aggressive for some 24 and 25 fps
content. This patch relaxes the limit to 0.75 seconds.

The patch also adds a new minimum interval variable
to replace the current hard wired value. This allows us
to impose a limit on the maximum number of primary
arfs per second for high frame rate (e.g. 50 & 60fps)
content. This is to address concerns regarding playback
performance on some platforms if there is a high base
frame rate and very frequent arfs.

Change-Id: I373e8b6b2a8ef522eced6c6d2cceb234ff763fcf
2015-05-01 15:11:49 +01:00
paulwilkins
effd974b16 Limit arf interval for low fpf clips.
This patch limits  the maximum arf interval length to
approximately half a second. In some low fps animations in
particular the existing code was selecting an overly long interval
which was hurting visual quality. For a sample problem test clip
(360P animation , 15fps, ~200Kbit/s) this change also improved
metrics by >0.5 db.

There may be some clips where this hurts metrics a little, but the
worst case impact visually is likely to be less than having an
interval that is much too long. On more normal material at 24
fps or higher, the impact is likely to be nil/minimal.

Change-Id: Id8b57413931a670c861213ea91d7cc596375a297
2015-04-16 11:50:37 +01:00
Deb Mukherjee
791bf5657f Merge "Some rate control adjustments to control overshoot" 2015-03-12 11:10:59 -07:00
Adrian Grange
39d20c6ac3 Merge "Clamp rate correction factor after scaling it" 2015-03-11 16:09:49 -07:00
Adrian Grange
42a89eb8cc Clamp rate correction factor after scaling it
Added clamp on the rate correction factor after
it has been scaled.

Change-Id: I5d4b46a101987b43c5bcfd7e0bd1b7b4d53640a4
2015-03-11 09:08:15 -07:00
Deb Mukherjee
0308e2ee6d Some rate control adjustments to control overshoot
Some rate control adjustments to control overshoot
in the constrained quality mode.

Change-Id: I8907b9a883642d779009d0a138adfa6ba67e7f41
2015-03-10 17:25:10 -07:00
Marco
340260585c Merge "Modify update golden reference update under aq-mode=3 mode." 2015-03-10 11:48:10 -07:00
Marco
fb31aa09e2 Modify update golden reference update under aq-mode=3 mode.
For non-SVC 1 pass CBR: make the GF update interval a multiple of the
cyclic refresh period, and use encoding stats to prevent GF update at certain times.

Change-Id: I4c44cacc2f70f1d27391a47644837e1eaa065017
2015-03-10 10:54:00 -07:00
paulwilkins
4b01a2d350 Merge "Allow q adjustment for VPX_CQ and VPX_CBR." 2015-03-10 10:45:02 -07:00
Adrian Grange
78df712216 Fix vp9_compute_qdelta_by_rate loop behavior
The return value from vp9_compute_qdelta_by_rate, which is
a delta value for the quantizer, could never be 0 if
(qindex == rc->worst_quality).

This occurs because target_index was setup unconditionally
in the loop and yet the loop counter stopped at
(rc->worst_quality - 1).

Change-Id: I6b59cd9b5811ff33357e71cd7d814c5e53d291f2
2015-03-10 09:14:54 -07:00
paulwilkins
2cff9c4efe Allow q adjustment for VPX_CQ and VPX_CBR.
Adjustment previously only enabled in VBR mode.

This patch allows adjustment of min and max q for CBR
and adjustment of max q only for CQ mode.

Change-Id: Id5e583f3d50453cd544fc57249acacd946457482
2015-03-09 17:13:55 +00:00
Yaowu Xu
c5718a7aa3 Merge "Fix an encoder/decode mismatch bug" 2015-02-13 16:40:41 -08:00
Yaowu Xu
4bc7f4828f Fix an encoder/decode mismatch bug
This commit prevent the encoder to update last_frame_type when a frame
is dropped in the encoder. Prior to this fix, if there is a dropped
frame immediatedly after a key frame, decoder would have the value of
last_frame_type as key frame, different from encoder as the dropped
frame in encoder would have updated the value to an inter frame. This
leads to different probability update in encoder and decoder, thereby
encoder/decoder mismatch.

This fixes issue #941

Change-Id: I27115224b138bec43ae3916c016574f5740822b0
2015-02-13 15:45:47 -08:00
Adrian Grange
053625e4cd Add cast to convert double to int
Change-Id: I7f63c2940256a5dadf9a29a853809290dd9e98ed
2015-02-11 15:59:48 -08:00
Adrian Grange
23ebacdb81 Auto-adaptive encoder frame resizing logic
Note: This feature is still in development.

Add an option for the encoder to decide the resolution
at which to encode each frame.

Each KF/GF/ARF goup is tested to see if it would be
better encoded at a lower resolution. At present, each
KF/GF/ARF is coded first at full-size and if the coded
size exceeds a threshold (twice target data rate) at
the maximum active Q then the entire group is encoded
at lower resolution.

This feature is enabled in vpxenc by setting:
  --resize-allowed=1

In addition, if the vpxenc command line also specifies
valid frame dimensions using:
  --resize-width=XXXX & --resize_height=YYYY
then *all* frames will be encoded at this resolution.

Change-Id: I13f341e0a82512f9e84e144e0f3b5aed8a65402b
2015-02-10 09:59:32 -08:00
Paul Wilkins
f752da8ce2 Change to update of rate control factors.
Remove damping parameter and use the damping
formula introduced by Yaowu Xu in all cases.

Change-Id: I18db7e0d0f262d5140102f259ab07821d374d285
2015-01-28 15:44:53 -08:00
Paul Wilkins
0bff1efc2b Bug when last group before forced key frame is short.
Just before a forced key frame we often get a foreshortened
arf/gf group. In such a case, we do not want to update
rc->last_boosted_qindex, which is used to define the Q range
for the forced key frame itself.

This gives a small average metrics gain for the YT and YT-HD sets
(eg. YT SSIM +0.141%).

Change-Id: Ie06698bc4f249e87183b8f8fb27ff8f3fde216d9
2015-01-21 15:25:57 -08:00
Frank Galligan
4c4d7261e4 Fix potential integer overflow.
ioc found a potential integer overflow in the rate control.

This is related to https://code.google.com/p/webm/issues/detail?id=821

Change-Id: Ib6c4acd6e964972f932fce7490592eb134f2b7ea
2014-12-05 08:02:12 -08:00
Marco
a047e7cdf8 Increase delta-qp for aq=3 mode, after key frame.
For a few refresh periods after key frame, use large qp-delta
to increase quality ramp-up.

Change-Id: Ib5a150fb2dfa6bafd0d4e6b5d28dfd0724b61319
2014-12-03 13:04:45 -08:00
Marco Paniconi
83fd18977f Cyclic refresh: factor segment delta-q into rate control.
Incorporate segment delta-q into estimated bits.
This generally improves the rate control under cyclic refresh (aq=3) mode.

Change-Id: I1dc60fb230e7d08357fae18909d8ed27bf58e037
2014-12-01 16:56:43 -08:00
Yaowu Xu
e4234b3f8b Separate rate_correction_factor for boosted GFs
When the golden frame is boosted, the rate correction factor is not
correlated well with other inter frames even in CBR mode. This commit
changes to use GF specific rate_correction_factor when gf_cbr_boost
is greater than 20%.

Change-Id: I6312c1564387bcacc11f4c5e8a9cfdc781b5c3ab
2014-11-25 14:32:07 -08:00
Yaowu Xu
21db24efcb Add a reset to rc tracking for dropped frames
VP9/DatarateTestVP9Large.ChangingDropFrameThresh/[34] fails post the
merge of commit#ffa06b37. This commit adds reset of rc tracking info
when frame is dropped, and fixes the causes of the bad interaction
between the tests and the previous commit.

Change-Id: I848acfd9fcb336359662274325190f94aac76eae
2014-11-19 15:32:11 -08:00
Yaowu Xu
587f0cd39d Merge "Prevent severe rate control errors in CBR mode" 2014-11-18 16:56:06 -08:00
Marco
3c715863da Merge "Modify active_worst_quality setting for one pass CBR." 2014-11-18 11:22:18 -08:00
Yaowu Xu
ffa06b3708 Prevent severe rate control errors in CBR mode
In rare cases, the interaction between rate correction factor and Q
choices may cause severe oscillating frame sizes that are way off
target bandwidth. This commit adds tracking of rate control results
for last two frames, and use the information to prevent oscillating
Q choices.

Change-Id: I9a6d125a15652b9bcac0e1fec6d7a1aedc4ed97e
2014-11-18 09:05:57 -08:00
Marco
b660f723b4 Modify active_worst_quality setting for one pass CBR.
Current setting had active_worst_quality set too high (close to worst_quality)
for first frame(s) following first key frame. This changes that to be somewhat
more aggressive in allowing active_worst_quality to be lower following key frame.

Also remove the 4/5 reduction in active_worst for key frame as
this should be set by the user qp_max setting.

Change-Id: I0530b3ddcc85c00e3eb7568de1b14a31206c4a4c
2014-11-17 11:46:49 -08:00
Yaowu Xu
e4e85ad4a8 Merge "adapt the adjustment limit for rate correction factor in RTC mode" 2014-11-13 15:50:30 -08:00
Adrian Grange
0d085ebc0a Prepare for dynamic frame resizing in the recode loop
Prepare for the introduction of frame-size change
logic into the recode loop.

Separated the speed dependent features into
separate static and dynamic parts, the latter being
those features that are dependent on the frame size.

Change-Id: Ia693e28c5cf069a1a7bf12e49ecf83e440e1d313
2014-11-13 11:41:20 -08:00
Yaowu Xu
9f79259e54 adapt the adjustment limit for rate correction factor in RTC mode
Rate correction factor is used to correct the estimated rate for any
given quantizer, and feeds into rate control for quantizer selection.
We make use of the actual bits used to calculate this rate correction
factor with an adjustment limit to prevent over-adjustment.

This commit adapts the adjustment limit to the difference between the
estimated bits and the actual bits, allows the adjustment limit to vary
between 0.125 (when estimate is close to actual) and 0.625 (when there
is >10X factor off between estimated and actual bits). By doing this,
the commit appears to have largely corrected two observed issues:
1. Adjustment is too slow when the actual bits used is way off from
estimate due to the small adjustment limit.
2. Extreme oscillating quantizer choices due to the feedback loop.

Change-Id: I4ee148d2c9d26d173b6c48011313ddb07ce2d7d6
2014-11-13 11:26:52 -08:00
Yaowu Xu
f2b978e895 Use normal rate_correction_factor for gf in CBR mode
I0c5f010 changed to allow update golden reference buffer in CBR mode,
this commit changes the use of rate_correction_factor for those frames
to be aligned with the new usage. This commit attempts to solve two
issues:

a. Initialization of rate correction factor for Golden Frame
Prior to this patch, even the regular inter frame has been update
the rate correction factor based on content and encoding results,
the first golden frame would still use the ininitialized value
that can be way off.

b. Allowing rate correction factor update to be slightly faster
Prior to this patch, when the rate correction factor is off, the
update to the factor is too slow, the factor could not get close
to a semi-correct value even after many frames.

The commit helps all clips in psnr/ssim metric, but especially to
a few clip in RTC set that rate correction was way off. For example
thaloundeskmtgvga gained about .5dB for both overall/average psnr.

Change-Id: I0be5c41691be57891d824505348b64be87fa3545
2014-11-10 16:55:13 -08:00
Yaowu Xu
7d7b43b9af Merge "Allow update of golden refernce buffer in CBR mode" 2014-10-28 10:48:02 -07:00
Yaowu Xu
e5cd51880e Allow update of golden refernce buffer in CBR mode
This commit changes to allow the usage of golden reference frame in
VP9 CBR mode to improve quality. VP9 supports potentially up to 8
reference buffers, it has reference buffers available for this
purpose. This was not possible in VP8 as golden and alt-ref buffers
were used for temporal scalability purpose in CBR mode in WebRTC.

For frames that update golden frame, there can be a quality boost.
The amount of allowed bitrate boost can be controlled via parameter
rc_max_inter_bitrate_pct. The inital value of the boost ratior is
currently based on over_shoot_pct. Further experiments will work
out the adaption of this boost value.

Change-Id: I0c5f010c8fd8b7b598f69779c1b30e5b2ac30a4d
2014-10-28 09:31:10 -07:00
Yaowu Xu
aa2af3ff6e Merge "Add a new control of max bitrate for inter frame" 2014-10-27 08:11:54 -07:00
Yaowu Xu
636099f7b6 Add a new control of max bitrate for inter frame
Change-Id: I205de3611622cff7f751ea8baf9f82784581730a
2014-10-24 10:19:28 -07:00
Paul Wilkins
8fc3ab774f Enable dual arf with constant q.
Add second level arf Q adjustment when using dual arfs
in constant Q mode.

Previously in constant Q mode enabling dual arf hurt by ~5%
but with this change the average benefit is ~1-1.5% with some
mid range data points up ~10%.

Note however that it still hurts on some clips including
some very low motion show content.

Change-Id: I5b7789a2f42a6127d9e801cc010c20a7113bdd9b
2014-10-23 13:19:31 +01:00
Paul Wilkins
716ae78ce4 Change initialization of static_scene_max_gf_interval.
This removes an unnecessary restriction that causes
a problem (noticed by AWG) when the forced key frame
interval is set to a very small value, such as 10. In this case
we were being forced to code minimal length GF groups.

Change-Id: I76ef5861a09638ff51f61fea02359554184ada53
2014-10-16 16:18:29 +01:00
Paul Wilkins
f7f0eaa581 Add adaptation option for VBR.
Allow min and maxQ to creep when the undershoot
or overshoot exceeds thresholds controlled by the
command line under_shoot_pct and over_shoot_pct
values.

Default is 100%,100% which ~disables adaptation.

Derf results for example undershoot% / overshoot%:-

Head:- Mean abs (%rate error) = 14.4%

This check in:-
25%/25% - Mean abs (%rate error) = 6.7%
                  PSNR hit -1% SSIM -0.1%

5% / 5%  - Mean abs (%rate error) = 2.2%
                 PSNR hit -3.3% SSIM - 1.1%

Most of the remaining error and most of the quality hit is
at extreme data rates. The adaptation code still has an
exception for material that is in effect static so that we
don't over adjust and over spend on YT slide show type
content.

(Rebase of If25a2449a415449c150acff23df713e9598d64c9
to resolve a auto-merge error)

Change-Id: Iec4e1613ef0d067454751d8220edb7058dfbd816
2014-10-13 10:16:44 +01:00
Alex Converse
a90255c366 Revert "Add adaptation option for VBR."
This reverts commit 869d4ca519.

This breaks the build via conflict with
e18edd5eb6.

Change-Id: If544b99e367a449452834eb8cce600f58c34ec0d
2014-10-10 11:34:00 -07:00
Paul Wilkins
169949dd74 Merge "Add adaptation option for VBR." 2014-10-10 09:22:58 -07:00
Paul Wilkins
869d4ca519 Add adaptation option for VBR.
Allow min and maxQ to creep when the undershoot
or overshoot exceeds thresholds controlled by the
command line under_shoot_pct and over_shoot_pct
values.

Default is 100%,100% which ~disables adaptation.

Derf results for example undershoot% / overshoot%:-

Head:- Mean abs (%rate error) = 14.4%

This check in:-
25%/25% - Mean abs (%rate error) = 6.7%
                  PSNR hit -1% SSIM -0.1%

5% / 5%  - Mean abs (%rate error) = 2.2%
                 PSNR hit -3.3% SSIM - 1.1%

Most of the remaining error and most of the quality hit is
at extreme data rates. The adaptation code still has an
exception for material that is in effect static so that we
don't over adjust and over spend on YT slide show type
content.

Change-Id: If25a2449a415449c150acff23df713e9598d64c9
2014-10-10 12:54:16 +01:00