Commit Graph

63 Commits

Author SHA1 Message Date
Michael Niedermayer
1a53c8dcfc 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>
(cherry picked from commit 55d7371fe0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-23 13:15:16 +02:00
Ronald S. Bultje
e44f0fa939 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).

(cherry picked from commit be885da342)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-23 13:15:16 +02:00
Ronald S. Bultje
d837407ae0 vp9: add support for resolution changes in inter frames.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit e8b4f6d6be)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2015-11-26 01:38:16 +01:00
James Zern
c6e16ec711 vp9/update_prob: prevent out of bounds table read
the max value of the lookup in expanded form is:
(((1 << 7) - 1) << 1) - 65 + 1 + 64 = 254

add one entry of padding to inv_map_table[] to prevent out of bounds
access with non-conforming / fuzzed bitstreams

Signed-off-by: James Zern <jzern@google.com>
Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit e91f860ea7)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-08-20 14:38:26 +02:00
Andreas Cadhalpun
9da5ba1f57 vp9: change type of tile_size from unsigned to int64_t
Otherwise the check 'tile_size < size' treats a negative size as
unsigned, causing the check to pass. This subsequently leads to
segmentation faults.

This was originally fixed as part of Libav commit 72ca83, so the
original author is one of the following developers:
        Anton Khirnov <anton@khirnov.net>
        Diego Biurrun <diego@biurrun.de>
        Luca Barbato <lu_zero@gentoo.org>
        Martin Storsjö <martin@martin.st>

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
(cherry picked from commit b18eac7ff2)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-08-20 14:29:12 +02:00
Ronald S. Bultje
54d40b7c45 vp9: fix segmentation map retention with threading enabled.
Fixes ticket 4359.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit efff3854f0)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 03:34:22 +02:00
Steve Lhomme
2a6f0c7e07 fix VP9 packet decoder returning 0 instead of the used data size
See https://trac.videolan.org/vlc/ticket/14022#comment:6

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 4851db80a4)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-29 03:34:22 +02:00
Ronald S. Bultje
f3b8cd7481 vp9: make above buffer pointer 32-byte aligned.
Fixes ticket #4383

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 1fd1f58bd6)
2015-03-21 14:27:37 -03:00
Michael Niedermayer
2a85826e57 avcodec/vp9: Use av_malloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-25 22:55:11 +02:00
Ronald S. Bultje
14e3025518 vp9: ignore reference segmentation map if error_resilience flag is set.
Fixes ffvp9_fails_where_libvpx.succeeds.webm from ticket 3849.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-13 20:46:00 +02:00
Timothy Gu
9bc0410e4f vp9: remove unused assignment
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Reviewed-by: BBB
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-16 14:38:42 +02:00
Michael Niedermayer
aab23f5ddd avcodec/vp9: fix () in macros
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-06-18 03:13:37 +02:00
Michael Niedermayer
2f2629c870 Merge commit '6d69f9f37689c999815a65a2d99999fad3a41705'
* commit '6d69f9f37689c999815a65a2d99999fad3a41705':
  vp9: write uveob as 16-bit value for 16x16/32x32 transforms.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-25 13:55:44 +02:00
Ronald S. Bultje
6d69f9f376 vp9: write uveob as 16-bit value for 16x16/32x32 transforms.
This fixes make fate-vp9-00-quantizer-01 THREADS=2.
2014-04-25 07:51:39 -04:00
James Almer
c7b089048d vp9: use LOCAL_ALIGNED_32 for left/top intra_pred pointers
This is needed for future AVX2 implementations

Signed-off-by: James Almer <jamrial@gmail.com>
Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-25 06:13:15 +02:00
Ronald S. Bultje
21a0451167 vp9: split decode_coeff_b loop inside txsz branch.
The advantage of this is that the is32x32 division branch in
decode_coeffs_b is removed from the inner loop to outside the block
coef decoding loop in decode_coeffs. Also, it allows us to merge the
txsz branches from the block coef decoding loop, the context merge
and the context split.
2014-02-17 13:39:00 +01:00
Clément Bœsch
c333987876 vp9: fix compilation with !HAVE_FAST_64BIT.
Spotted-by: Carl Eugen Hoyos <cehoyos@ag.or.at>
2014-02-09 18:44:20 +01:00
Ronald S. Bultje
0d4d223353 vp9: invert order in l[] intra prediction array.
The directional intra predictors either don't care about order (dc, h,
dc_left, tm), or they prefer inverted order (vr, dr, hd). This allows
more efficient SIMD implementations.
2014-02-09 18:07:15 +01:00
Ronald S. Bultje
37c6eac296 vp9: remove memset in loopfilter level setting loop.
Use same function for segmentation map writing also.
2014-02-09 18:07:14 +01:00
Ronald S. Bultje
45245e202e vp9: coef decoding context-splat speedup. 2014-02-09 18:07:14 +01:00
Ronald S. Bultje
fccd7d81b6 vp9: decode_mode context optimizations. 2014-02-09 18:07:14 +01:00
Ronald S. Bultje
1dc8559e25 vp9: more aligned zeroes. 2014-02-09 18:07:14 +01:00
Ronald S. Bultje
0c30c8ddc1 vp9: faster skip-block coefficient blanking. 2014-02-09 18:07:14 +01:00
Ronald S. Bultje
cdfcd06126 vp9: coef context reading optimization. 2014-02-09 18:07:14 +01:00
Ronald S. Bultje
9aeca1c572 vp9: just disallow temporal or no-update segmentation on size-change.
The spec doesn't describe how it should be decoded so this is probably
the safest thing to do. Fixes valgrind errors on fuzzed11.ivf and fixes
valgrind errors on fuzzed10.ivf differently.
2014-02-09 18:07:14 +01:00
Ronald S. Bultje
0c67864a37 vp9: don't allow retaining old segmentation maps after a size change.
Fixes valgrind warnings on fuzzed10.ivf.
2014-02-08 22:08:20 +01:00
Ronald S. Bultje
7f0f47b3df vp9: some variable re-arrangements for alignment. 2014-02-08 18:30:17 +01:00
Ronald S. Bultje
af63ea7078 vp9: re-allocate block buffers on uses_2pass change w/o size change.
Fixes valgrind errors and crashes in fuzzed9.ivf.
2014-02-08 18:30:17 +01:00
Ronald S. Bultje
bbc3425fa2 vp9: fix mix-up of last-frame/cur-frame in frame size checks.
Fixes invalid reads in fuzzed7.ivf.
2014-02-08 11:18:37 +01:00
Ronald S. Bultje
c2871568cf vp9: fix invalid ref frame w/h on size change.
Fixes invalid reads and crashes in vp90-2-05-resize.webm and fuzzed6.ivf.
The output is still not identical to what libvpx does (because we don't
actually scale in MC).

Reviewed-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-26 20:16:01 +01:00
Ronald S. Bultje
d9343c3484 vp9: disable use_last_frame_mvs on resolution change (scalable).
Prevents some invalid memory accesses after resolution change in
vp90-2-05-resize.webm, and libvpx does this too.

Reviewed-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-26 20:15:45 +01:00
Ronald S. Bultje
4147b337c1 vp9: fix memory corruption if header decoding fails after size change. 2014-01-24 19:25:26 -05:00
Ronald S. Bultje
0065d2d520 vp9: fix mt-related hang a parser infinite loop.
Fixes trac ticket 3274.

Looked-at-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-11 22:35:14 +01:00
Michael Niedermayer
3773738e26 Merge commit 'ca96e337169093979d7c763064ad9dae12b3108c'
* commit 'ca96e337169093979d7c763064ad9dae12b3108c':
  vp9: drop support for real (non-emulated) edges

Conflicts:
	libavcodec/vp9block.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-09 14:41:23 +01:00
Ronald S. Bultje
024fac5cd4 vp9: make mv bounds 32bit.
Fixes an assert in file from trac ticket 3188.
2014-01-07 20:43:35 -05:00
Ronald S. Bultje
5b0fc07819 vp9: reset contextual caches on frame size change with mt enabled.
Fixes crash/valgrind errors in trac ticket 3188 and hang in 3274.
2014-01-07 20:43:35 -05:00
Ronald S. Bultje
acafbb4dd2 vp9: fix crash if segmentation=1, keyframe/intraonly=1 and updatemap=0.
The reference map is never used in such cases, but we accidently copied
it anyway. This could cause crashes if this map has not yet been
allocated. Fixes trac ticket 3188.

Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-24 11:43:53 +01:00
Ronald S. Bultje
4a55bffad3 vp9: fix bug in updating of coef probabilities with parallelmode=1.
Fixes trac ticket 3228.

Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-12-24 11:43:08 +01:00
Ronald S. Bultje
f068aed7b8 vp9: make decode_coeffs() return value void.
It was previously int and would return error if decode_coeffs_b()
returns an error; however, that can never happen, so refactor all
that code to make all dependent functions return void also (all the
way up to decode_coeffs_sb()).
2013-11-30 16:26:14 -05:00
Ronald S. Bultje
47c6d9403d vp9: cosmetics. 2013-11-30 16:26:14 -05:00
Ronald S. Bultje
76bd878d95 vp9: add a 2-pass decoding mode, and add frame-mt support.
For a random 1080p sample, decoding time went from 9.7sec (1 threads)
to 6.0sec (2 threads) and 5.2sec (4 threads) in 2-pass decoding mode.
I don't have any samples that use the parallelmode feature, but the
gains should be higher.
2013-11-30 16:26:13 -05:00
Ronald S. Bultje
46955ae430 vp9: allocate 'b', 'block/uvblock' and 'eob/uveob' dynamically. 2013-11-30 16:26:13 -05:00
Ronald S. Bultje
fc7d910b2e vp9: split last/cur_frame from the reference buffers.
We need more information from last/cur_frame than from reference
buffers, so we can use a simplified structure for reference buffers,
and then store mvs and segmentation map information in last/cur.
2013-11-30 16:26:13 -05:00
Ronald S. Bultje
39b244002a vp9: move some entries out of VP9Block into VP9Context.
They aren't really block-related variables in the sense that they are
not block-coded, rather they are state trackers.
2013-11-30 16:26:12 -05:00
Ronald S. Bultje
84d362f020 vp9: split packet parsing into an AVParser. 2013-11-30 16:26:12 -05:00
Ronald S. Bultje
816737ea5d vp9: use proper refcounting.
Based on something similar in libav. Author is likely Anton Khirnov
<anton@khirnov.net> but I'm not sure.
2013-11-30 16:26:12 -05:00
Clément Bœsch
484f8d77c6 avcodec/vp9: assert on sane size in update_size().
w and h are both read as uint16 + 1 so this can not happen. A similar
change was introduced in 97962b2 / 72ca830, with the
av_log()+AVERROR_INVALIDDATA form, suggesting it could be triggerable
somehow.

Change suggested by Ronald S. Bultje.
2013-11-16 22:47:54 +01:00
Clément Bœsch
c20a7ce62d avcodec/vp9: remove some reset-to-zero from vp9_decode_free().
Those should not be necessary.

Original change by one of these developers:
    Anton Khirnov <anton@khirnov.net>
    Diego Biurrun <diego@biurrun.de>
    Luca Barbato <lu_zero@gentoo.org>
    Martin Storsjö <martin@martin.st>

See 97962b2 / 72ca830
2013-11-16 22:34:23 +01:00
Clément Bœsch
7e704b1e10 avcodec/vp9: add a never triggerable assert.
vp8_rac_get_tree() is called with a tree of size 3, so the returned
value can not be outside [0;3]. All of the [0;3] cases are handled in
the switch, so the assert should not be triggerable by any means. A
similar change was introduced in 97962b2 / 72ca830, with the
av_log()+AVERROR_INVALIDDATA form, suggesting it could be triggerable
somehow. This assert might help static analyzer, or simply the reader.
2013-11-16 22:34:23 +01:00
Martin Storsjö
ab80d7e8c5 vp9: Ensure that the arithmetic coder values are read in the right order
The operands of an addition can be evaluated in any order, since
the addition isn't a sequence point. The only operators that
have a defined evaluation order are &&, ||, ?: and the sequence
operator ','.

This fixes fate-vp9 on ARM RVCT.
2013-11-16 20:25:25 +01:00