Commit Graph

268 Commits

Author SHA1 Message Date
Ranjit Kumar Tulabandu
71061e9332 Row based multi-threading of encoding stage
(Yunqing Wang)
This patch implements the row-based multi-threading within tiles in
the encoding pass, and substantially speeds up the multi-threaded
encoder in VP9.

Speed tests at speed 1 on STDHD(using 4 tiles) set show that the
average speedups of the encoding pass(second pass in the 2-pass
encoding) is 7% while using 2 threads, 16% while using 4 threads,
85% while using 8 threads, and 116% while using 16 threads.

Change-Id: I12e41dbc171951958af9e6d098efd6e2c82827de
2017-02-15 00:49:34 +00:00
Yunqing Wang
318ca07657 The bitstream bit match test in multi-threaded encoder
While the new-mt mode is enabled(namely, allowing to use row-based
multi-threading in encoder), several speed features that adaptively
adjust encoding parameters during encoding would cause mismatch
between single-thread encoded bitstream and multi-thread encoded
bitstream. This patch provides a set_control API to disable these
features, so that the bit match bitstream is obtained in the unit
test.

Change-Id: Ie9868bafdfe196296d1dd29e0dca517f6a9a4d60
2017-02-13 13:02:26 -08:00
Ranjit Kumar Tulabandu
8b0c11c358 Multi-threading of first pass stats collection
(yunqingwang)
1. Rebased the patch. Incorporated recent first pass changes.
2. Turned on the first pass unit test.

Change-Id: Ia2f7ba8152d0b6dd6bf8efb9dfaf505ba7d8edee
2017-01-24 15:48:02 -08:00
James Zern
c42a281439 vp9_cx_iface,encoder_encode: check validate_img return
before calling vp9_apply_encoding_flags() which may crash if the
resolution was invalid. this is the same change as:
c0523090b vp8e_encode: check validate_config return

BUG=https://bugzilla.mozilla.org/show_bug.cgi?id=1315288

Change-Id: Icd2aab322422e83d3a778fca6d7789e5000239d7
2017-01-13 16:53:03 -08:00
hui su
337ad83e58 Add support for VP9 level targeting
Constraints on encoder config:
-target_bandwidth is no larger than 80% of level bitrate limit
-target_bandwidth * (1 + max_over_shoot_pct) is no larger than
88% of level bitrate limit
-min_gf_interval is no smaller than level limit
-tile_columns is no larger than level limit

Constraints on rate control:
-current frame size plus previous three frames' size is no larger
than the CPB level limit
-current frame size is no larger than 50%/40%/20% of the CPB
level limit if it's a key/alt-ref/other frame.

Change-Id: I84d1a2d6d6e3c82bfd533b3309ce999cfaba2c8b
2017-01-06 10:07:31 -08:00
Yaowu Xu
0ffbb36ddc Add validation of frame_parallel_decoding_mode
This is a boolean value that is written into bitstream, any value other
than 0 or 1 could have led to unexpected behavior. This commit fix the
issue by adding validation of the value to make sure it is boolean.

BUG=webm:1339

Change-Id: I2d3e69e8dbefcab9a0db9cb39a91a40ce531c5a1
2016-11-21 10:53:25 -08:00
clang-format
5f6d143b41 apply clang-format
Change-Id: I501597b7c1e0f0c7ae2aea3ee8073f0a641b3487
2016-09-15 15:07:53 -07:00
Yury Gitman
d7c20079a6 Add --alt-ref-aq=<int> option
In the future this option will activate adaptive quantization special
for altref frames. Encoder will  create the adaptive quantization map
on the basis of lookahead buffers similarity which is the estimate of
the future motion compensation performance.

Change-Id: Ia0088b3babb0f9a4899c79d8d819947ba5a03df2
2016-08-24 15:49:25 -07:00
clang-format
08131055e4 vp9/decoder,vp9/*.[hc]: apply clang-format
Change-Id: Ic38ea06c7b2fb3e8e94a4c0910e82672a1acaea7
2016-08-03 14:29:31 -07:00
jackychen
8ce67d714a vp9 svc: Enable different speed setting for each spatial layer.
This change only affects 1 pass cbr svc mode.

Change-Id: If0da87bb200f7e7762755340c40c8157cc7a16ca
2016-07-25 15:11:43 -07:00
Yaowu Xu
98431cde07 Fix encoder crashes for odd size input
Change-Id: Id5c30c419282369cc8c3280d9a70b34a859a71d8
2016-07-12 11:11:26 -07:00
Yunqing Wang
0a075cb39c Make set_reference control API work in VP9
Moved the API patch from NextGenv2. An example was included.
To try it, for example, run the following command:
$ examples/vpx_cx_set_ref vp9 352 288 in.yuv out.ivf 4 30

Change-Id: I4cf8f23b86d7ebd85ffd2630dcfbd799c0b88101
2016-07-01 17:58:02 -07:00
Tom Finegan
5a9f21db54 Output frames in first pass for VPX_DL_REALTIME.
Since combining VPX_DL_REALTIME with VPX_RC_FIRST_PASS is basically
nonsense, ignore the user's pass setting when this happens and
behave as if the requested encode is a single pass encode.

BUG=webm:1233

Change-Id: I5ee4c4e5838c4ca6d24988890aae490b10826db2
2016-06-17 11:25:55 -07:00
Yaowu Xu
1387f5550f Fix ubsan warning: vp9_cx_iface.c
BUG=https://bugs.chromium.org/p/webm/issues/detail?id=1219

Change-Id: I77584af8b9e25db484d9ced6013da3163a9592c0
2016-06-16 08:28:33 -07:00
hui su
72d4890caf Add vp9 encoder API VP9E_GET_LEVEL to provide bitstream level
Change-Id: I1ef3df0192491035728fe9d5eb25cc66dc2965de
2016-06-15 12:53:28 -07:00
hui su
3c206aca04 Fix typos in control function for VP9E_SET_TARGET_LEVEL
Change-Id: Ic797c6be579c3434681a5e9dbb3900ae49c43958
2016-05-11 20:23:52 -07:00
hui su
be3f0698b0 Add VP9 encoder API for level specification.
Add control API VP9E_SET_TARGET_LEVEL that allows the encoder to
control the output bitstream level and/or keep level related
statistics.

Usage:
               255         do not care about level (default)
               0           keep level related stats only
               10          target for level 1
               11          target for level 1.1
               .
               .
               .
               62          target for level 6.2

Usage for vpxenc:

--target-level=0/255/10/11...

Change-Id: I31d1aeca19358b893e7577b4e63748c8e614034a
2016-05-10 11:48:16 -07:00
James Zern
715d3bbd05 Merge "Add a TODO for using tile rows while encoding with multiple threads" 2016-03-24 03:57:28 +00:00
Johann Koenig
813221a163 Merge "Allows sub-second frame rates in vp9" 2016-03-23 20:04:59 +00:00
Yunqing Wang
5486e1d8f3 Add a TODO for using tile rows while encoding with multiple threads
Added a TODO in vp9_cx_iface.c.

Change-Id: Ib987f20cab8417340a23ae676616de1df48e8a12
2016-03-23 12:23:02 -07:00
Yunqing Wang
dc5f7712f2 Prevent encoder crash caused by row tile dependencies
In multi-thread case, the encoder may crash if using encoder option
tile-rows > 0. To prevent that, force tile-rows=0 in this situation.
This is a workaround for WebM issue 1095:
https://bugs.chromium.org/p/webm/issues/detail?id=1095

The further fix can be done by adding synchronizations after a tile
row is encoded. But this will hurt multi-threaded encoder performance.
So, it is recommended to use tile-rows=0 while encoding with threads
> 1.

Change-Id: I656cbcc200f8d0410d09530e7981ad8f32fe7bc9
2016-03-22 16:15:12 -07:00
Johnny Klonaris
76108b4269 Allows sub-second frame rates in vp9
This is the identical change submitted for vp8 here:
https://chromium-review.googlesource.com/#/c/274107/

Tested this change on Mac OSX (10.10) and Linux
(Linux Mint 17 / Ubuntu 14.04) and in both cases:

- downloaded and compiled latest source for libvpx and ffmpeg
- confirmed ffmpeg would build sub-second frame rate webm files
  via the previous patch
- confirmed ffmpeg would *not* build fps < 1 for vp9
- made this change, recompiled libvpn and ffmpeg
- confirmed ffmpeg would now create the same webm with
  fps < 1
- confirmed the resulting file would play and was vp9 (e.g.
  would not play in Firefox (Linux version complained it was
  VP9 but mostly could play it) or older vlc, etc., but does
  play just fine in Google Chrome and a newer version of vlc.

Sorry I didn't catch this last time - but this seems a solid
change and it's handy to be able to create frame rates
less than one second.

-jk

Change-Id: I38fa32148de8c4c359f228cf08b9a4b83b5a52fb
2016-03-12 21:06:31 -08:00
James Zern
14828e756f vp9: set kf_max_dist to a reasonable default (128)
the same as vp8, with the same reasoning from:
2a0d7b1 Reduce the default kf_max_dist to 128.

see also:
https://trac.ffmpeg.org/ticket/4904
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815673

+ restore vpxenc behavior of taking the library default rather than
  forcing 5s

This change also exposes an issue with one-pass svc in cbr mode, keep
the old default in datarate_test.cc for now.

Change-Id: Id6d1244f42490b06fefc1a7b4e12a423a1f83e88
2016-02-25 12:34:12 -08:00
James Zern
73f45fcf0b vp9,encoder: relocate setjmp
move to encoder_encode() as vp9_get_compressed_data() allocates data and
would require some modification to make its error return meaningful.

Change-Id: I8ddc390a1441afd0ff937842fa4ad1053c956133
2016-02-16 19:25:54 -08:00
James Zern
0b9925ccec vp9_cx_iface,encode: remove redundant cpi check
this is allocated in init(), a NULL pointer on encode() should be
treated as a failure.

Change-Id: I3f55ea4a98be616bb5ab74d95ce4a3d6262e734a
2016-02-16 18:10:01 -08:00
Marco
b0027b96ae vp9-svc: Fix to allow setting qp-max/min per spatial and temporal layer.
Change-Id: Ic0ec32c1d7f7c08c9f956592dccbfd9060b1f624
2015-11-23 10:46:34 -08:00
James Zern
849e54cedd Merge "vp8cx: remove deprecated reference/entropy controls" 2015-10-20 02:46:36 +00:00
James Zern
a046f56491 vp8cx: remove deprecated reference/entropy controls
VP8E_UPD_ENTROPY, VP8E_UPD_REFERENCE and VP8E_USE_REFERENCE have been
deprecated since the initial public release

Change-Id: Ied16b441eec13434d85f1ab115d49ccaf5f2f7b0
2015-10-16 17:02:36 -07:00
Yaowu Xu
568429512e Add a new enum type vpx_color_range_t
to make meaning of color_range obvious.

Change-Id: I303582e448b82b3203b497e27b22601cc718dfff
2015-10-16 16:27:18 -07:00
Marco
1ce01eaaf7 VP9-SVC: Bugfix to allow skipping lower layer(s) encoding.
The setting of svc->spatial_layer_to_encode was missing
in VP9E_SET_SVC_LAYER_ID.

Change-Id: I015b1a64adb9ef2644d6477a02d9d9364c8462b9
2015-10-12 16:11:34 -07:00
Marco
7266bedc04 Add first_spatial_layer_to_encode to SVC.
Use the existing VP9_SET_SVC control to set the
first spatial layer to encode.

Since we loop over all spatial layers inside the encoder, the
setting of spatial_layer_id via VP9_SET_SVC has no relevance.
Use it instead to set the first_spatial_layer_to_encode,
which allows an application to skip encoding lower layer(s).

Change only affects the 1 pass CBR SVC.

Change-Id: I5d63ab713c3e250fdf42c637f38d5ec8f60cd1fb
2015-10-06 08:56:15 -07:00
Ronald S. Bultje
812945a8f1 vp9/10: improve support for render_width/height.
In the decoder, map this to the output variable vpx_image_t.r_w/h.
This is intended as an improved version of VP9D_GET_DISPLAY_SIZE,
which doesn't work with parallel frame decoding. In the encoder,
map this to a codec control func (VP9E_SET_RENDER_SIZE) that takes
a w/h pair argument in a int[2] (identical to VP9D_GET_DISPLAY_SIZE).

Also add render_size to the encoder_param_get_to_decoder unit test.

See issue 1030.

Change-Id: I12124c13602d832bf4c44090db08c1009c94c7e8
2015-09-25 22:18:22 -04:00
Marco
730cdefd3e Add SVC codec control to set frame flags and buffer indices.
Add SVC codec control to set the frame flags and buffer indices
for each spatial layer of the current (super)frame to be encoded.
This allows the application to set (and change on the fly) the
reference frame configuration for spatial layers.

Added an example layer pattern (spatial and temporal layers)
in vp9_spatial_svc_encoder for the bypass_mode using new control.

Change-Id: I05f941897cae13fb9275b939d11f93941cb73bee
2015-09-17 09:37:15 -07:00
Ronald S. Bultje
eeb5ef0a24 Add support for color-range.
In decoder, export (eventually) into vpx_image_t.range field. In
encoder, use oxcf->color_range to set it (same way as for
color_space).

See issue 1059.

Change-Id: Ieabbb2a785fa58cc4044bd54eee66f328f3906ce
2015-09-16 06:41:46 -04:00
Debargha Mukherjee
3c5244886a Fixes part of merge regression from adding arf parameters.
From Change  Ibf0c30b72074b3f71918ab278ccccc02a95a70a0
There is still an issue relating to one animated test clip with repeat
patterns where this change effectively increase the default  maximum
arf interval by +1. This can be examined seperately.

Change-Id: Idd01d5480fc45202d8a059a0c3afc0997cc5bdd1
2015-07-14 18:32:38 +01:00
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
a8c5ab2ca6 Remove ABI check for 1 pass CBR SVC.
Remove the ABI check for the controls needed for SVC 1 pass CBR mode.
Bump up the ABI version.

Change-Id: I35b79ee010e14af83c6d1e801d574deaaa2fc7eb
2015-06-03 17:43:22 -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
Alex Converse
4dcb839607 VP9E_GET_ACTIVE_MAP API function.
This is useful when aq mode 3 (cyclic refresh) reactivates segments for refresh.

Change-Id: I3ad1d9410b899ede393d82bb8db14e2da4d84eca
2015-03-24 11:19:47 -07:00
James Zern
fef91c9040 vp[89]_cx_iface.c: remove obsolete ABI checks
Change-Id: I49a7017e8adc18ff03d748cb328814a8a3e1bcf6
2015-03-20 14:50:14 -07:00
James Zern
18613408a3 put spatial svc behind an ABI check
this removes the CONFIG_* checks from public headers, but means
'--enable-experimental --enable-spatial-svc' builds will fail without a
local change to the ABI in vpx_encoder.h. this should be all right for
testing this experiment.

Change-Id: Ief55e7b9d1e8332cfce990275e04c29b30af0c4a
2015-03-19 12:29:16 -07:00
Alex Converse
6126afe62e Fix external resize memory issues.
These were uncovered by the chromoting perftest.

Change-Id: Ia5a90fd1718ff757c1484decf3861295260e6722
2015-03-16 15:56:26 -07:00
Yaowu Xu
268f10669a Provide information on codec controls
The commit updates the comments in vp8cx.h to make it clear which
codec support each of codec control functions.

Change-Id: Ibf876e289d4325bbb61ce19311da60d384624c2f
2015-03-13 11:56:35 -07:00
Yaowu Xu
416529069b Rename a vp9 only control with vp9e prefix
Also updated comments and doc to make it clear that the control is
supported in VP9 only.

Change-Id: I6f120b65135fc1185695e9e3dc29fbe0d430824b
2015-03-12 18:33:47 -07:00
Deb Mukherjee
a437f7b980 Merge "Reduce default overshoot/undershoot params to 25" 2015-03-09 09:21:35 -07:00
Deb Mukherjee
7a386d83eb Reduce default overshoot/undershoot params to 25
Reducing these values from 100 makes rate control tighter by
default.

Change-Id: I979409c93e6f19e128898f08ad581bf67eb0f824
2015-03-05 14:00:03 -08:00
Frank Galligan
93a0189936 Use 8 threads by default for VP9 encodes
BUG=https://code.google.com/p/webm/issues/detail?id=964

Change-Id: I70679d0f139b8e0962f7e19eb56b34060953e9b0
2015-03-03 17:05:17 -08:00
Frank Galligan
f5c36a5ced VP9: turn on tile-columns and frame-parallel-mode by default
Most of the current decoders use tile-based multithreading. Also
most of the current decoders need frame_parallel_decoding_mode
turned on to enable multithreaded decoding. tile-columns is
limited by resolution, so setting to max (6) is fine.

BUG=https://code.google.com/p/webm/issues/detail?id=963

Change-Id: I6e7ac3485d96bf0c69e06706cbb326dd38be0020
2015-03-03 11:20:11 -08:00
Yaowu Xu
754bbcfdc8 Fix the encoder to support profile change
Change-Id: Iefb928ad1174e274409facfb44f80265ff0f7683
2015-02-26 11:41:01 -08:00
paulwilkins
8d7f53f04c Account for rate error in GF group Q calculation.
When GF group adaptive maxQ is enabled this patch accounts
somewhat for accumulated error in the rate control.

This improves accuracy quite a bit on many clips especially
when there is  overshoot.

Examples when the overshoot and undershoot command line
parameters are set to 100:

Hall @ 1200 overshoot is reduced from 67-24%.
Akiyo @ 400 undershoot is reduced from 28%-15%.

Setting a lower value for undershoot or overshoot still
reduces the error further.

Impact on metrics is mixed with some gains in average psnr
but generally a little lower (e.g. 0.5%) on overall and ssim.

The GF group adaptation is still off by default in this patch.
Compared to with the head, enabling this mode now gives
big average psnr gains on the YT sets (e.g. YT_HD >11.2%),
a drop in overall PSNR (YT-HD 3.9%) and a smaller drop or
neutral for SSIM.

Change-Id: If4b32cd0740d3fb941317b374f9c2951954eee90
2015-02-23 10:57:27 +00:00