Commit Graph

59 Commits

Author SHA1 Message Date
paulwilkins
f9865d1701 Removed unused data structure.
Removed unused element from TWOPASS data structure.

Change-Id: I9b662fd8eea727a7978055bc14f7c7328f048a5e
2016-06-03 13:18:09 +01:00
paulwilkins
cd700e1ab9 Adjustment calculation of active worst quality.
Added a factor based on the bit spend in the last arf group vs the
target to adjust the choice of the active worst quality in subsequent
groups.

Helps clips where previously there was a big overshoot or undershoot
to adapt and get closer to the target rate.

Change-Id: I67034b801679b99024409489a2273ea6fe23b8e6
2016-06-03 13:17:21 +01:00
paulwilkins
4328b08521 Remove gf_zeromotion_pct.
The use of this value is preventing rate adjustment on clips
or sections that have very little motion but high noise and
this can give rise to some sections with massive overshoot.

Change-Id: I9a65c7c1148dc5d3a7d8b23e50fc1733f3661621
2016-06-03 12:13:03 +01:00
Debargha Mukherjee
c47c460f69 Step towards making the 2-pass cq mode perceptual
Uses a metric on fraction of smooth blocks derived from first pass
stats in a frame to adjust down the cq_level modestly in the cq mode.
The current implementation does not add much complexity, and is
fairly light in the adaptation.

Change-Id: Ic484e810d5bd51b7bb6b8945f378c7c3d9d27053
2016-04-09 06:24:18 -07:00
James Zern
c6eadc3309 vp9_firstpass: make vp9_init_subsampling private
Change-Id: I03b2ae99ec2e212c76bf815de7d5745b5c965d57
2015-08-28 18:54:08 -07:00
paulwilkins
a126b6ce7d Change speed and rd features for formatting bars.
Change speed features / behavior for split mode when there
is an internal active edge (e.g. formatting bars).

Remove some threshold constraints in rd code near the active
edge of the image.

Add some plumbing for left and right active edge detection.

Patch set 5. Limit rd pass through for sub 8x8 to internal active edges.
This takes away any speed penalty for most clips but keeps the enhanced
edge coding for the more critical case of internal image edges

Change-Id: If644e4762874de4fe9cbb0a66211953fa74c13a5
2015-07-08 17:51:42 +01:00
Paul Wilkins
faf8c63b0f Changes to active maxq calculation in two pass.
Some initial experiments into discounting dead zone
formating bars and intra skip blocks (common in some
types of animation and graphics) in the calculation of
the active max Q for each ARF/GF group.

TODO: check for vertical formating bars and validate the
horizontal bar at the bottom edge of the image.

As expected, this change as it stands, does not make much
difference for the natural videos in the std-hd and derf sets.
However, for the yt and yt hd set there is a significant rise
in the average PSNR with overall PSNR and SSIM remaining
neutral.

The mean rise for the YT-HD test set was > 6%. This is mainly
because the change allows Q to drop further on titles and
other graphics sections where spending a small number of
extra bits gives a sharp rise in PSNR.

Change-Id: I3f878ae91fc1854312d7ecf9fa792c17bc1aa6b7
2015-06-09 15:31:24 +01:00
Paul Wilkins
4a28da5843 Enable more split modes for animated content.
For content that is identified as likely to contain some
animation or graphics content, increase the availability
of split modes for good quality speeds 1-3.

On a problem test animation clip this improves metrics
results by about 0.25 db and makes a noticeable difference
visually. It also causes a small drop in file size (~0.5%) but
a rise in encode time of about 5-6% at speed  2.

For more normal content it should have no effect.

Change-Id: Ic4cd9a8de065af9f9402f4477a17442aebf0e439
2015-06-09 14:50:44 +01:00
Paul Wilkins
668e804504 Animation and dead zone detection.
Adds code to detect dead zone bars at the top and bottom
of reformatted letterbox video (note that the code only
looks at the top of the image and assumes any dead zone
is symmetrical).  Use of this to adapt rate control etc.
will follow in a subsequent patch.

Also counts other blocks (excluding the dead zone) that
have no intra signal. The presence of a significant
number of such blocks can be used as a identify that the frame
may be artificial (e.g.  animation, screen capture, graphics).
This patch contains plumbing only and does not use
the signal.

Change-Id: I59bc93529cd4065416cef773e405fda3ae006a20
2015-06-04 01:01:20 +01: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
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
fd070220ff Adjust active maxq for GF groups.
Currently disabled by default: enabled using
#define GROUP_ADAPTIVE_MAXQ

In this patch the active max Q is adjusted for each GF
group based on the vbr bit allocation and raw first pass
group error.

This will tend to give a lower q for easy sections
and a higher value for very hard sections. As such it is
expected to improve quality in some of the easier
sections where quality issues have been reported.

This change tends to hurt overall psnr but help
average psnr. SSIM also shows a small gain.

Average results for derf, yt, std-hd and yt-hd test sets were
as follows (%change for average psnr, overal psnr and ssim):-

derf +0.291, - 0.252, -0.021
yt +6.466, -1.436, +0.552
std-hd +0.490, +0.014, +0.380
yt-hd +5.565, - 1.573, +0.099

Change-Id: Icc015499cebbf2a45054a05e8e31f3dfb43f944a
2015-01-26 14:55:36 -08:00
Paul Wilkins
fc47c5d653 Add adaptive midpoint for AQ1.
Make the midpoint variance used in AQ mode 1 segmentation
depend on the overall complexity of the frame in two pass.

Change-Id: I452814ec57f7a32352e41bb250e78066abe952dd
2014-11-20 18:37:34 -08:00
Paul Wilkins
5e935126a6 Add intra complexity and brightness weight to first pass.
The aim of this patch is to apply a positive weighting to
frames that have a significant number of blocks that are
of low spatial complexity and are dark. The rationale behind
this is that artifacts tend to be more visible in such frames.

In this patch the weight is only applied in regard to the distribution
of bits between frames. Hence if all the frames share similar
characteristics (as is the case for most of our short test clips) there
will be little or no net effect.

However, the effect can be seen on some longer form test content.

For example Tears of steel baseline test:
2323.09 Kbit/s opsnr 39.915 ssim 74.729
With this patch:-
2213.34 Kbit/s opsnr 39.963 ssim 74.808
(Sligtly better metrics and about 5% smaller)

The weighting may well need some further tuning along side changes
to the aq modes.

Change-Id: Ieced379bca03938166ab87b2b97f55d94948904c
2014-11-06 10:45:00 +00: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
Yunqing Wang
e18edd5eb6 Allow mode search breakout at very low prediction errors
In model_rd_for_sb function, the spatial domain SSE and variance
are checked to see if transform coefficients are quantized to 0.
Besides that, this patch adds another set of thresholds that are
much more strict. These thresholds are used to conduct a partition
block level check to measure if all its TX blocks are skippable
for YUV planes. If it is true, x->skip is set for this partition
block, and thus its mode search is terminated.

This speeds up the encoding at very low prediction error case,
such as screen sharing application. This patch covers what
rd_encode_breakout_test() does, so that function is removed.

Borg test at speed 3 shows:
For stdhd set, psnr: +0.008%, ssim: +0.014%;
For derf set, psnr: +0.018%, ssim: +0.025%.
No noticeable speed change.

Change-Id: I4e5f15cf10016a282a68e35175ff854b28195944
2014-10-08 17:46:22 -07:00
Paul Wilkins
c389b37bb4 Substantial reworking of code for arf and kf groups.
Substantial restructuring of the way we estimate
the rate of decay in prediction quality and determine
the arf interval and amount of boost used.

Also other changes to support moving to a lower first pass
Q which exposes some new features and allows us to better
distinguish genuinely static blocks from low motion or noisy
blocks.

Net gains now visible on all the test sets with std-hd PSNR up
1.87%. There are still some bad outlier cases but most of these
are low motion or slide show type content where the metrics
are already high at any given rate. The best + case is up by
more than 10%.

Change-Id: I18e25170053bdf3188f493ff8062f48a74515815
2014-09-18 12:53:48 +01:00
Dmitry Kovalev
80fd1419f5 Removing source field from VP9_COMP.
Using local variables instead.

Change-Id: I68737f7e392b81492ffd3ef2c2ff9afbf55fb097
2014-08-22 16:57:58 -07:00
Pengchong Jin
233e0ccc73 Store first pass motion vector directions
Re-organize the one-byte structure for 16x16 first pass
block. Add bits to indicate motion vector directions.

Change-Id: Id10754ba343dfc712c7fed5bcc85c67fa0bbcb89
2014-08-04 16:17:47 -07:00
Pengchong Jin
bae652245d Store block-wise statistics obtained in the first pass
Change-Id: I9956db2ba2f7d28f484daaf5022d8d1ef5db473c
2014-07-28 09:12:40 -07:00
Pengchong Jin
ac638125ea Merge "Fixed a bug of setting wrong first pass mb stats pointer" 2014-07-17 14:24:52 -07:00
Pengchong Jin
e358ab5fc9 Fixed a bug of setting wrong first pass mb stats pointer
The bug sets the wrong pointer to the first pass mb stats
if the encoder does the re-coding in the second pass.

Change-Id: I8a11f45dd7dceb38de814adec24cecccae370d00
2014-07-17 12:04:15 -07:00
Paul Wilkins
93960c869e Merge "Changes to rd balance and multi-arf bug fix." 2014-07-17 07:01:31 -07:00
Paul Wilkins
b691230dea Changes to rd balance and multi-arf bug fix.
2 pass only change to calculation of rd mult based on Q.
Make a small adjustment based on frame type and also
replace adjustment based on iifactor with an one based
on the ambient GF/ARF boost level.

Also fix multi arf bug / issue.

Overall these change give an slight improvement in ssim
but hurt psnr a little.

Change-Id: I5e1751e3ff5390a26f543d7855059e6fbcce105e
2014-07-16 13:58:47 +01:00
Pengchong Jin
f349b071c6 Rewrite functions related to first pass block stats
Change-Id: I28679f88e2911b06eef5cbc83ecb62b8c69e4c53
2014-07-14 17:45:27 -07:00
Pengchong Jin
aaabbd67b2 Store/read 16x16 block statistics obtained from the first pass
Add a conditional compile flag for this feature. Also add a
switch to enable the encoder to use these statistics in the
second pass. Currently, the switch is turned off.

Change-Id: Ia1c858c35ec90e36f19f5cffe156b97ddaa04922
2014-07-01 16:47:17 -07:00
Paul Wilkins
60244ec1f4 Dual ARF changes: Buffer index selection.
Add indirection to the section of buffer indices.
This is to help simplify things in the future if we
have other codec features that switch indices.

Limit the max GF interval for static sections to fit
the gf_group structures.

Change-Id: I38310daaf23fd906004c0e8ee3e99e15570f84cb
2014-06-24 16:30:44 +01:00
Paul Wilkins
2e430cba61 Experiment for mid group second arf.
This patch implements a mechanism for inserting a second
arf at the mid position of arf groups.

It is currently disabled by default using the flag multi_arf_enabled.

Results are currently down somewhat in initial testing if
multi-arf is enabled. Most of the loss is attributable to the
fact that code to preserve the previous golden frame
(in the arf buffer) in cases where we are coding an overlay
frame, is currently disabled in the multi-arf case.

Change-Id: I1d777318ca09f147db2e8c86d7315fe86168c865
2014-06-24 12:59:14 +01:00
Dmitry Kovalev
eaeda536a4 Removing unused ssim_weighted_pred_err field from FIRSTPASS_STATS.
Change-Id: Ia8c7e3905ac21732cb6b8099eaf8df72c7e36b73
2014-06-12 11:28:54 -07:00
Adrian Grange
a4f747921a Revert "Removing this_frame_stats member from TWO_PASS struct."
Use of stack frame variable "fps" beyond the lifetime of the function.

fps is sent as a paremeter to output_stats and stored in the
packet holding this encoded frame. This has scope beyond the
lifetime of the calling function.

This reverts commit 3f95a230c7

Change-Id: Icd8e14b3d7dd733590ada12e619b9dce95b6b0f5
2014-06-06 12:51:56 -07:00
Dmitry Kovalev
3f95a230c7 Removing this_frame_stats member from TWO_PASS struct.
Change-Id: Id8877fad1f1e88b145e7c40c43174109b9c4f373
2014-05-27 17:09:28 -07:00
Paul Wilkins
1edbaeb09d Further first pass allocation changes.
Further changes to first pass allocation for gf/arf groups.
Three variables removed from TWO_PASS structure as only
now used locally. Dont adjust gf_group_bits in the post
encode update as this will no longer have any effect.

Change-Id: Iff89b225db923fc856f5d2aedbc899f1d7d68b55
2014-05-23 20:21:25 +01:00
Paul Wilkins
03eb06212a Re-factor bit allocation in first pass.
Restructuring to allocate the bits for each frame in
a GF group at the time the group is defined.

At the moment the allocation closely mirrors what
we had before.

Also changes the default rate adjustment method to
LONG_TERM_VBR_CORRECTION.

Change-Id: Ie5793c46c6b9c888cead5d8790792efd7d60b7c1
2014-05-23 18:01:54 +01:00
Dmitry Kovalev
b2be554351 Cleaning up vp9_init_second_pass().
modified_error_total from TWO_PASS struct is not required anymore.

Change-Id: I0e07cac1e6d1b6a78418116be725bcd72bfbd847
2014-05-22 13:04:43 -07:00
Paul Wilkins
e9ed051c83 Merge "Cosmetic clean up." 2014-05-20 02:34:56 -07:00
Paul Wilkins
f07a96fdc1 Cosmetic clean up.
Use type TWO_PASS instead of "struct twopass".

Change-Id: I9d92920893bd436537b2ca19e9c9d355cca56c7c
2014-05-19 11:14:02 +01:00
Dmitry Kovalev
3181290ee8 Removing unused fields from twopass_rc struct.
Change-Id: Iaece070e9d1305ac3d8df9d3431fefa6e20ac0ec
2014-05-15 11:12:45 -07:00
Dmitry Kovalev
c3de569bb9 Cleaning up vp9_twopass_worst_quality().
Change-Id: Ie144e9ece57f2d59c230704a2f166bda1042adeb
2014-04-09 21:06:11 -07:00
Deb Mukherjee
97f4fb7b5f Rate ctrl changes to track target bitrates closer
Turns off the DISABLE_RC_LONG_TERM_MEM macro and makes other changes
in the way the bits are updated, to make 2-pass rate control track
target bitrates closer.

Change-Id: I5f3be4b11c2908e6a9a9a1dd4fcf4e65531c44d8
2014-04-02 11:16:20 -07:00
Minghai Shang
86394d2636 [svc] Fix SvcTest.SecondPassEncode failure
Root cause is the different default register length between x86
and x64 platform. Change spatial_layer_id to long long.

Change-Id: If1a5972365c7a59f7e76cb4fd714610f3d48a8ff
2014-03-28 13:59:08 -07:00
Minghai Shang
d205335060 [svc] Finalize spatial svc first pass rate control
1. Save stats for each spatial layer
      2. Add frame buffer management for svc first pass rc
      3. Set default spatial layer to 1
      4. Flush encoder at the end of stream in test app
This only supports spatial svc.
Change-Id: Ia89cfa87bb6394e6c0405b921d86c426d0a0c9ae
2014-03-19 11:06:20 -07:00
Dmitry Kovalev
d6b8709eb0 Moving static_scene_max_gf_interval to RATE_CONTROL struct.
Change-Id: Id63e114a8f0615dbafd6a816019cdebffb983d2c
2014-03-10 17:29:15 -07:00
Dmitry Kovalev
cca347ed4e Adding const to FIRSTPASS_STATS pointers.
Change-Id: Ia94d757de1d1b24609128cd40e68558078f50a38
2014-03-06 18:58:17 -08:00
Yaowu Xu
673621c8ba vp9_firstpass.c: remove unused functions & params
Change-Id: I111c5bd0dd47db7b1f6952c18056bee548bb42e9
2014-03-02 13:46:03 -08:00
Deb Mukherjee
d23e339202 Removes active_worst_quality feedback
Removes certain cases of feedback of active_worst_quality,
and removes it from the RATE_CONTROL structure. Now active
worst quality is expected to be computed locally in the
q picking function during the encode.
Making temporal filter strength depend on avg_frame_qindex
rather than on active_worst_quality actually improves
performance esp. for yt.
derf: +0.038%
yt: +0.359%

Change-Id: I1fe5a343034b55af9322289165321f00ac0827b1
2014-02-11 16:59:56 -08:00
Deb Mukherjee
15fb5510a8 Further one-pass vbr rate control changes
Some parameter changes and fixes on one-pass rate control.
derfraw300 is now only 10% below 2-pass speed 0 rate control.

Change-Id: I1940eef8a5a035dc18e71b880d5e00cabd1f01b9
2014-02-10 14:27:19 -08:00
Dmitry Kovalev
1976dd616d Moving twopass_rc and FIRSTPASS_STATS to vp9_firstpass.h.
Change-Id: I5c942ee1a04eb0d7f2ae7ba8ea8ce47e666550c5
2014-02-05 18:28:28 -08:00