Commit Graph

169 Commits

Author SHA1 Message Date
Ronald S. Bultje
b823bbc10c vp9: split out loopfilter functions in their own source file. 2017-03-28 18:04:26 -04:00
Ronald S. Bultje
f8c019944d vp9: re-split the decoder/format/dsp interface header files.
The advantage here is that the internal software decoder interface is
not exposed to the DSP functions or the hardware accelerations.
2017-03-28 18:04:26 -04:00
Clément Bœsch
5dd37c6847 lavc/vp9: clarify inv_recenter_nonneg
Ends up identical to Libav.
2017-03-27 21:38:21 +02:00
Clément Bœsch
37814a21cb lavc/vp9: consistent use of typedef instead of struct 2017-03-27 21:38:21 +02:00
Clément Bœsch
875f695576 lavc/vp9: misc cosmetics
Imported from Libav
2017-03-27 21:38:21 +02:00
Clément Bœsch
ff8436ba76 lavc/vp9: rename res to ret 2017-03-27 21:38:21 +02:00
Clément Bœsch
0f8ae9d7b2 lavc/vp9: split a few assignment out of ifs 2017-03-27 21:38:21 +02:00
Clément Bœsch
f4d95e0949 lavc/vp9: rename {ref,unref,alloc}_frame to frame_{ref,unref,alloc}
For consistency with Libav.
2017-03-27 21:38:21 +02:00
Clément Bœsch
12c44d6373 lavc/vp9: rename ctx to avctx
This reduces diff with Libav. It also prevents a potential confusion
between the private context and the AVCodecContext.
2017-03-27 21:38:21 +02:00
Clément Bœsch
1c9f4b5078 lavc/vp9: split into vp9{block,data,mvs}
This is following Libav layout to ease merges.
2017-03-27 21:38:21 +02:00
Michael Niedermayer
55d7371fe0 avcodec/vp568: Check that there is enough data for ff_vp56_init_range_decoder()
Fixes: timeout in 730/clusterfuzz-testcase-5265113739165696 (part 1 of 2)

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Reviewed-by: BBB
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-07 21:29:12 +01:00
Mathieu Velten
49e8e5fc56 avcodec/vaapi-vp9: add support for profile 2 (bpp > 8)
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2016-12-05 22:12:34 +00:00
Mathieu Velten
b1f630f1a6 avcodec/vp9: move bpp to the shared context for use in hwaccel
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2016-12-05 22:12:26 +00:00
Martin Storsjö
1f7801c2bc aarch64: vp9: Add NEON optimizations of VP9 MC functions
This work is sponsored by, and copyright, Google.

These are ported from the ARM version; it is essentially a 1:1
port with no extra added features, but with some hand tuning
(especially for the plain copy/avg functions). The ARM version
isn't very register starved to begin with, so there's not much
to be gained from having more spare registers here - we only
avoid having to clobber callee-saved registers.

Examples of runtimes vs the 32 bit version, on a Cortex A53:
                                     ARM   AArch64
vp9_avg4_neon:                      27.2      23.7
vp9_avg8_neon:                      56.5      54.7
vp9_avg16_neon:                    169.9     167.4
vp9_avg32_neon:                    585.8     585.2
vp9_avg64_neon:                   2460.3    2294.7
vp9_avg_8tap_smooth_4h_neon:       132.7     125.2
vp9_avg_8tap_smooth_4hv_neon:      478.8     442.0
vp9_avg_8tap_smooth_4v_neon:       126.0      93.7
vp9_avg_8tap_smooth_8h_neon:       241.7     234.2
vp9_avg_8tap_smooth_8hv_neon:      690.9     646.5
vp9_avg_8tap_smooth_8v_neon:       245.0     205.5
vp9_avg_8tap_smooth_64h_neon:    11273.2   11280.1
vp9_avg_8tap_smooth_64hv_neon:   22980.6   22184.1
vp9_avg_8tap_smooth_64v_neon:    11549.7   10781.1
vp9_put4_neon:                      18.0      17.2
vp9_put8_neon:                      40.2      37.7
vp9_put16_neon:                     97.4      99.5
vp9_put32_neon/armv8:              346.0     307.4
vp9_put64_neon/armv8:             1319.0    1107.5
vp9_put_8tap_smooth_4h_neon:       126.7     118.2
vp9_put_8tap_smooth_4hv_neon:      465.7     434.0
vp9_put_8tap_smooth_4v_neon:       113.0      86.5
vp9_put_8tap_smooth_8h_neon:       229.7     221.6
vp9_put_8tap_smooth_8hv_neon:      658.9     621.3
vp9_put_8tap_smooth_8v_neon:       215.0     187.5
vp9_put_8tap_smooth_64h_neon:    10636.7   10627.8
vp9_put_8tap_smooth_64hv_neon:   21076.8   21026.9
vp9_put_8tap_smooth_64v_neon:     9635.0    9632.4

These are generally about as fast as the corresponding ARM
routines on the same CPU (at least on the A53), in most cases
marginally faster.

The speedup vs C code is pretty much the same as for the 32 bit
case; on the A53 it's around 6-13x for ther larger 8tap filters.
The exact speedup varies a little, since the C versions generally
don't end up exactly as slow/fast as on 32 bit.

This is an adapted cherry-pick from libav commit
383d96aa22.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2016-11-15 15:10:03 -05:00
Martin Storsjö
68caef9d48 arm: vp9: Add NEON optimizations of VP9 MC functions
This work is sponsored by, and copyright, Google.

The filter coefficients are signed values, where the product of the
multiplication with one individual filter coefficient doesn't
overflow a 16 bit signed value (the largest filter coefficient is
127). But when the products are accumulated, the resulting sum can
overflow the 16 bit signed range. Instead of accumulating in 32 bit,
we accumulate the largest product (either index 3 or 4) last with a
saturated addition.

(The VP8 MC asm does something similar, but slightly simpler, by
accumulating each half of the filter separately. In the VP9 MC
filters, each half of the filter can also overflow though, so the
largest component has to be handled individually.)

Examples of relative speedup compared to the C version, from checkasm:
                       Cortex      A7     A8     A9    A53
vp9_avg4_neon:                   1.71   1.15   1.42   1.49
vp9_avg8_neon:                   2.51   3.63   3.14   2.58
vp9_avg16_neon:                  2.95   6.76   3.01   2.84
vp9_avg32_neon:                  3.29   6.64   2.85   3.00
vp9_avg64_neon:                  3.47   6.67   3.14   2.80
vp9_avg_8tap_smooth_4h_neon:     3.22   4.73   2.76   4.67
vp9_avg_8tap_smooth_4hv_neon:    3.67   4.76   3.28   4.71
vp9_avg_8tap_smooth_4v_neon:     5.52   7.60   4.60   6.31
vp9_avg_8tap_smooth_8h_neon:     6.22   9.04   5.12   9.32
vp9_avg_8tap_smooth_8hv_neon:    6.38   8.21   5.72   8.17
vp9_avg_8tap_smooth_8v_neon:     9.22  12.66   8.15  11.10
vp9_avg_8tap_smooth_64h_neon:    7.02  10.23   5.54  11.58
vp9_avg_8tap_smooth_64hv_neon:   6.76   9.46   5.93   9.40
vp9_avg_8tap_smooth_64v_neon:   10.76  14.13   9.46  13.37
vp9_put4_neon:                   1.11   1.47   1.00   1.21
vp9_put8_neon:                   1.23   2.17   1.94   1.48
vp9_put16_neon:                  1.63   4.02   1.73   1.97
vp9_put32_neon:                  1.56   4.92   2.00   1.96
vp9_put64_neon:                  2.10   5.28   2.03   2.35
vp9_put_8tap_smooth_4h_neon:     3.11   4.35   2.63   4.35
vp9_put_8tap_smooth_4hv_neon:    3.67   4.69   3.25   4.71
vp9_put_8tap_smooth_4v_neon:     5.45   7.27   4.49   6.52
vp9_put_8tap_smooth_8h_neon:     5.97   8.18   4.81   8.56
vp9_put_8tap_smooth_8hv_neon:    6.39   7.90   5.64   8.15
vp9_put_8tap_smooth_8v_neon:     9.03  11.84   8.07  11.51
vp9_put_8tap_smooth_64h_neon:    6.78   9.48   4.88  10.89
vp9_put_8tap_smooth_64hv_neon:   6.99   8.87   5.94   9.56
vp9_put_8tap_smooth_64v_neon:   10.69  13.30   9.43  14.34

For the larger 8tap filters, the speedup vs C code is around 5-14x.

This is significantly faster than libvpx's implementation of the same
functions, at least when comparing the put_8tap_smooth_64 functions
(compared to vpx_convolve8_horiz_neon and vpx_convolve8_vert_neon from
libvpx).

Absolute runtimes from checkasm:
                          Cortex      A7        A8        A9       A53
vp9_put_8tap_smooth_64h_neon:    20150.3   14489.4   19733.6   10863.7
libvpx vpx_convolve8_horiz_neon: 52623.3   19736.4   21907.7   25027.7

vp9_put_8tap_smooth_64v_neon:    14455.0   12303.9   13746.4    9628.9
libvpx vpx_convolve8_vert_neon:  42090.0   17706.2   17659.9   16941.2

Thus, on the A9, the horizontal filter is only marginally faster than
libvpx, while our version is significantly faster on the other cores,
and the vertical filter is significantly faster on all cores. The
difference is especially large on the A7.

The libvpx implementation does the accumulation in 32 bit, which
probably explains most of the differences.

This is an adapted cherry-pick from libav commits
ffbd1d2b00,
392caa65df,
557c1675cf and
11623217e3.

Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2016-11-15 15:10:03 -05:00
Ronald S. Bultje
be885da342 vp9: change order of operations in adapt_prob().
This is intended to workaround bug "665 Integer Divide Instruction May
Cause Unpredictable Behavior" on some early AMD CPUs, which causes a
div-by-zero in this codepath, such as reported in Mozilla bug #1293996.

Note that this isn't guaranteed to fix the bug, since a compiler is free
to reorder instructions that don't depend on each other. However, it
appears to fix the bug in Firefox, and a similar patch was applied to
libvpx also (see Chrome bug #599899).
2016-10-24 16:02:39 -04:00
Hendrik Leppkes
3f9137c57d Merge commit '32c8359093d1ff4f45ed19518b449b3ac3769d27'
* commit '32c8359093d1ff4f45ed19518b449b3ac3769d27':
  lavc: export the timestamps when decoding in AVFrame.pts

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-10-07 13:03:36 +02:00
Denis Charmet
38f99017e6 vp9: Return the correct size when decoding a superframe
According to avcodec.h, avcodec_decode_video2 should return the number of
bytes used if a frame was decoded.

The current implementation returns size - used size of all the subframes.
This fixes the VLC's bug https://trac.videolan.org/vlc/ticket/16836.

The superframe is always fully consumed.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-06-05 16:58:04 +02:00
Ronald S. Bultje
ee729cc0ed vp9: ignore frame_context_index field in key-/intraonly-frames.
Reproduces a bug to remain consistent with libvpx' behaviour.
2016-04-17 09:28:56 -04:00
Ronald S. Bultje
b86339a9f8 vp9: fix a few signed integer left-shifts.
Fixes trac tickets 5127, 5129, 5130.
2016-03-11 16:06:29 -05:00
Ronald S. Bultje
5307adadeb vp9: only call ff_get_format on stream format changes.
In practice, this means we don't call it N times for N-threaded decoding.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-13 19:49:34 +01:00
Hendrik Leppkes
e760641720 lavc: add vp9 profiles to AVCodecDescriptor 2016-01-01 16:25:50 +01:00
Timo Rothenpieler
d7c2b75681 vaapi: Add VP9 hwaccell support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2015-12-22 12:54:23 +01:00
Hendrik Leppkes
1e6cf7272f avcodec: implement vp9 dxva2 hwaccel 2015-12-07 09:38:59 +01:00
Hendrik Leppkes
585083dd1f vp9: add hwaccel hooks 2015-12-07 09:25:02 +01:00
Hendrik Leppkes
cd1b7e2bd7 vp9: fix pixel format changes with threading 2015-12-07 09:23:18 +01:00
Ronald S. Bultje
1ac89869db vp9: always keep s->bytesperpixel and ctx->pix_fmt in sync.
Fixes mozilla bug 1229128.
2015-12-02 14:53:46 -05:00
Ronald S. Bultje
49d8a70dc5 vp9: uses ff_set_dimensions (which sets coded_width/height).
Fixes ticket 4935.
2015-10-24 15:11:59 -04:00
Hendrik Leppkes
e12908d71e vp9: use AVFrame.buf[0] to check if a frame is valid
AVFrame.data[0] is not guaranteed to be set with a HWAccel
2015-10-16 14:53:41 +02:00
Hendrik Leppkes
6e719dc6bb vp9: expose reference frames in VP9SharedContext 2015-10-15 13:02:23 +02:00
Ronald S. Bultje
b95f241b6e vp9: split header into separate struct and expose in vp9.h
This allows hwaccels to access the bitstream header information.
2015-10-15 13:02:20 +02:00
Ganesh Ajjanagadde
2cbaa078d1 avcodec: use HAVE_THREADS header guards to silence -Wunused-function
When compiled with --disable-pthreads, e.g
http://fate.ffmpeg.org/report.cgi?time=20150917015044&slot=alpha-debian-qemu-gcc-4.7,
a bunch of -Wunused-functions are reported due to missing header guards
around threading related functions.
This patch should silence such warnings.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-04 12:47:34 -04:00
Ronald S. Bultje
a0d8a81075 vp9: switch min_tile_cols location so it shifts up instead of down.
This fixes cases where the shifted number is 64, but we shifted non-
zero numbers away in the shift. The change makes behaviour consistent
with libvpx.
2015-09-15 09:20:34 -04:00
Ronald S. Bultje
a30a8beeb3 vp9: Fix emu[] edge overflow conditions for >8bpp/non-420. 2015-09-12 07:01:48 -04:00
Ronald S. Bultje
2563a33856 vp9: re-initialize internal buffers on bpp change also. 2015-09-12 07:01:47 -04:00
Ronald S. Bultje
fd8b90f5f6 vp9: fix overflow in 8x8 topleft 32x32 idct ssse3 version.
Also disable the mmx/iwht optimization when the bitexact flag is set.
With synthetically coded coefficients (i.e. these that lead to a
residual well outside the [-255,255] range), our optimizations will
overflow. It doesn't make sense to fix the overflows, since they can
only occur on synthetic input, not on real fwht-generated input. Thus,
add a bitexact flag that disables this optimization.
2015-09-10 07:51:16 -04:00
Ronald S. Bultje
4bb9dbe4d7 vp9: permanently delete segmentation refmap on any size change. 2015-09-10 07:51:16 -04:00
Ronald S. Bultje
ae9344cb9f vp9: check return value of ff_thread_ref_frame().
Fixes CID 1322309.
2015-09-05 15:50:01 -04:00
Ronald S. Bultje
1f7871ec42 vp9: fix edge copy for 10/12bpp frames. 2015-09-05 15:50:01 -04:00
Ronald S. Bultje
9cdeb105a6 vp9: do unscaled MC in scaled path if size of this reference matches.
This can happen if we do bidirectional MC, where one reference has the
same size as the current frame, but the other one doesn't.
2015-09-05 15:50:01 -04:00
Ronald S. Bultje
873dbc6758 vp9: sync segmentation.absolute_vals between threads. 2015-09-05 15:50:00 -04:00
Ronald S. Bultje
3d7173b509 vp9: always sync segmentation.feat between threads. 2015-09-05 15:50:00 -04:00
Ronald S. Bultje
4ecb8b4191 vp9: don't erase values for {lf,ref,skip,q}_enabled if segmentation=0.
Instead, use segmentation.enabled before accessing each of these values.
2015-09-04 09:33:45 -04:00
Ronald S. Bultje
8b45e87f64 vp9: fix segmentation map retention across keyframe boundaries. 2015-09-04 09:33:45 -04:00
Ronald S. Bultje
7cc7d13fe3 vp9: fix RGB chroma subsampling. 2015-09-04 09:33:45 -04:00
Ronald S. Bultje
ecd9f57edc vp9: read reserved bit in RGB header. 2015-09-04 09:33:45 -04:00
Ronald S. Bultje
48f641a18b vp9: clip intermediates in dequant calculations.
This makes values consistent with libvpx.
2015-09-04 09:33:45 -04:00
Ronald S. Bultje
eaff36c973 vp9: fix segmentation map retention if segmentation is turned off. 2015-09-04 09:33:44 -04:00
Ronald S. Bultje
8d25a11dc7 vp9: use resetctx in the same way as libvpx. 2015-09-04 09:33:44 -04:00
Ronald S. Bultje
cc9d3a3e36 vp9: fix indentation. 2015-09-04 09:33:44 -04:00