1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

107 Commits

Author SHA1 Message Date
Michael Niedermayer
a31e08fa1a avcodec/diracdec: Check numx/y
Fixes division by 0
Fixes: 60261c4469ba3e11059890fb2832a515/asan_generic_135e694_2790_beb94eaa0aeb7d11c0437375a8964a99.drc

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-20 19:36:01 +02:00
Rostislav Pehlivanov
000eb01a7d diracdec: fix unchecked byte length
Also drops the start variable since it's redundant.
Found by Coverity, fixes CID1363964

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-07-13 23:53:05 +01:00
Rostislav Pehlivanov
b2b12b2d4a diracdec: fix maximum quantization index checks
Found by Coverity, fixes CID1363961 and CID1363962

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-07-13 23:40:06 +01:00
Rostislav Pehlivanov
a337cb7361 diracdec: fix #coeffs -> byte conversion
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-07-12 10:44:24 +01:00
Rostislav Pehlivanov
2094562923 diracdec: do not memset the entire coefficient buffer for HQ pictures
This is now handled by the slice decoding function.

Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
2016-07-11 23:41:32 +01:00
Rostislav Pehlivanov
dcad4677d6 diracdec: do not allocate and free slice parameters every frame
Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
2016-07-11 23:40:57 +01:00
Rostislav Pehlivanov
0eb0f93109 diracdec: implement a LUT-based Golomb code parser
Still much left to optimize, but it provides a significant performance
improvement - 10% for 300Mbps (1080p30), 25% for 1.5Gbps (4k 60fps) in
comparison with the default implementation.

Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
2016-07-11 23:40:28 +01:00
Rostislav Pehlivanov
c43485f707 diracdec: rewrite HQ slice decoding
Now coefficients are written to a buffer and are then dequantized by the
new SIMD dequantization functions. For the lower bands without enough
coefficients to fill a register (and hence they overwrite) the C version
of the dequantization function is used.

The buffer is per-thread and will be realloc'd if anything changes.
This prevents regressions and having to limit slice size.

Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
2016-07-11 23:38:45 +01:00
Rostislav Pehlivanov
09d89d9406 diractab: expose the maximum quantization index as a macro
Prevents having to have random magic values in the decoder and a
separate macro in the encoder.

Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
2016-07-11 23:38:01 +01:00
Rostislav Pehlivanov
b9c6c5f453 diracdec: decode HQ profile slices in rows
Siginificantly improves the performance.

Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
2016-07-11 23:34:54 +01:00
Rostislav Pehlivanov
17caae7202 diracdec: simplify golomb parsing and dequantization
In preparation for the following commits, this commit simplifies the
coefficient parsing and dequantization function. It was needlessly
inlined without much performance gain.

Signed-off-by: Rostislav Pehlivanov <rpehlivanov@obe.tv>
2016-07-11 23:34:25 +01:00
Hendrik Leppkes
b20fe650ef Merge commit '4024b566d664a4b161d677554be52f32e7ad4236'
* commit '4024b566d664a4b161d677554be52f32e7ad4236':
  golomb: Give svq3_get_se_golomb()/svq3_get_ue_golomb() better names

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-06-26 15:12:48 +02:00
Michael Niedermayer
7ecfe4dc36 avcodec/diracdec: Fix potential integer overflow
Fixes CID1361948

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-19 18:13:29 +02:00
Michael Niedermayer
8f2a1990c0 avcodec/diracdec: check bitstream size related fields for overflows
Fixes segfault
Fixes Ticket5333

Regression since bfc8a4dabe
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-28 04:39:57 +02:00
Timothy Gu
671761d713 diracdec: Pass DWTPlane to dwt init 2016-02-07 09:09:13 -08:00
Timothy Gu
e04912c0b6 diracdec: Split DWTPlane struct from Plane 2016-02-07 09:09:13 -08:00
Timothy Gu
58ded09bd1 dirac_dwt: Rename init2 to init
The functions are all private.
2016-02-07 09:09:13 -08:00
Rostislav Pehlivanov
f021030365 diradec: split tables away to a separate diractab file
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-02-03 17:19:33 +00:00
Rostislav Pehlivanov
3bbe7862ec diracdec: move the MAX_DWT_LEVELS macro to dirac.h
Used by the VC-2 encoder.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-02-03 17:19:30 +00:00
Rostislav Pehlivanov
5776344a7b diracdec: fix original Dirac Low Delay profile
The version structure in the main decoder context was not (and
apparently has never been) populated since it was added.
Still, having VC-2 break the existing Dirac Low Delay mode was odd and
easily avoidable had the specifications authors noticed/cared.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-01-21 16:49:45 +00:00
Rostislav Pehlivanov
8248b51e0b diracdec: add support for 12 bit videos
The DSP lacked a function needed to convert signed to unsigned. This was
ignored when originally adding support and templating for bit depths
greater than 8. The 10 bit function was used for 12 bit pictures and
resulted in an improper conversion.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2016-01-21 14:48:32 +00:00
Michael Niedermayer
5fbd97fc75 avcodec/diracdec: Fix qfactor/offset tables
It seems the previous tables where calculated with 32bit integers ignoring
overflows.
Also check for the max qindex, the value is choosen so that the qfactor/offset
fit in int32.

Fixes: 070b7914fd5dfe8f93248bea71363410/asan_static-oob_c8d034_2764_258e20f4a3c79158aecddb61a833d756.drc
Fixes out of array reads

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-17 17:28:20 +01:00
Michael Niedermayer
39fb3f18c5 avcodec/diracdec: Handle the 0 vlc case at the top of coeff_unpack_golomb()
decoding changes from 17 to 20 fps

Reviewed-by; Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-13 18:56:49 +01:00
Michael Niedermayer
bbd9771625 avcodec/diracdec: Factor +2 out of the inner loop
Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-13 18:55:46 +01:00
Michael Niedermayer
da144c2ddd avcodec/diracdec: Inline svq3_get_ue_golomb() and merge the sign bit decoding into it
This avoids closing and opening the bit reader

Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-13 18:54:50 +01:00
Kieran Kunhya
bfc8a4dabe diracdec: Add slice threading to HQ profile 2016-01-13 16:08:56 +00:00
Andreas Cadhalpun
d637a58750 diracdec: fix idwt_stride calculation in bytes
The transformation to bytes must happen after alignment to get the same
resulting pointers as before.

This fixes segmentation faults in the assembler code.

The regression was introduced in commit 9553689.

Reviewed-by: Kieran Kunhya <kierank@obe.tv>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-01-12 00:12:36 +01:00
Michael Niedermayer
73840bbe4e avcodec/diracdec: Check ff_set_dimensions() for failure
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-17 19:00:33 +01:00
Michael Niedermayer
ffad6f6b89 avcodec/diracdec: fix aspect ratio (it was lost after efcc8fddd6)
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-12-17 19:00:18 +01:00
Hendrik Leppkes
efcc8fddd6 Merge commit 'e02de9df4b218bd6e1e927b67fd4075741545688'
* commit 'e02de9df4b218bd6e1e927b67fd4075741545688':
  lavc: export Dirac parsing API used by the ogg demuxer as public

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-12-17 14:48:46 +01:00
Kieran Kunhya
25f6ccccd6 diracdec: Fix codeblock parameters reading 2015-12-16 23:26:03 +00:00
Kieran Kunhya
a349a10edf diracdec: Add support for HQ profile 2015-12-16 21:35:12 +00:00
Rostislav Pehlivanov
d8f13e783a diracdec: remove duplicate codeblock decoding
Broken by commit 7424a6d0a5

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2015-12-10 22:50:58 +00:00
Kieran Kunhya
3652dd5d0c diracdec: Fix FPE on invalid low_delay data 2015-12-10 22:14:03 +00:00
Kieran Kunhya
cdf8c9038d diracdec: Replace dirac parse codes with better ones 2015-12-10 21:47:01 +00:00
Kieran Kunhya
7424a6d0a5 diracdec: Read picture types by using parse_code 2015-12-10 21:42:13 +00:00
Kieran Kunhya
8eb6acef92 diracdec: Support new extended quantiser range 2015-12-10 21:37:24 +00:00
Kieran Kunhya
8dcc99dc68 diracdec: Extract version parameters 2015-12-10 21:26:35 +00:00
Kieran Kunhya
9f374c5906 diracdec: Make slice parameters common between lowdelay and future hq profile 2015-12-10 21:04:04 +00:00
Kieran Kunhya
3bb6ce1af9 diracdec: Rename lowdelay_subband to decode_subband because it is shared with HQ profile 2015-12-10 19:11:21 +00:00
Kieran Kunhya
3f07f12f65 diracdec: Template DSP functions adding 10-bit versions 2015-12-10 18:25:02 +00:00
Kieran Kunhya
9553689854 diracdec: Move strides to bytes, and pointer types to uint8_t.
Start templating functions for move to support 10-bit
Parts of this patch were written by Rostislav Pehlivanov
2015-12-10 16:52:48 +00:00
Michael Niedermayer
cb5190bc9d avcodec/diracdec: Move reference to DiracFrame, avoid use of the deprecated field from AVFrame
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-06 12:44:37 +02:00
Michael Niedermayer
444e9874a7 Merge commit 'def97856de6021965db86c25a732d78689bd6bb0'
* commit 'def97856de6021965db86c25a732d78689bd6bb0':
  lavc: AV-prefix all codec capabilities

Conflicts:
	cmdutils.c
	ffmpeg.c
	ffplay.c
	libavcodec/8svx.c
	libavcodec/aacenc.c
	libavcodec/ac3dec.c
	libavcodec/adpcm.c
	libavcodec/alac.c
	libavcodec/atrac3plusdec.c
	libavcodec/bink.c
	libavcodec/dnxhddec.c
	libavcodec/dvdec.c
	libavcodec/dvenc.c
	libavcodec/ffv1dec.c
	libavcodec/ffv1enc.c
	libavcodec/fic.c
	libavcodec/flacdec.c
	libavcodec/flacenc.c
	libavcodec/flvdec.c
	libavcodec/fraps.c
	libavcodec/frwu.c
	libavcodec/gifdec.c
	libavcodec/h261dec.c
	libavcodec/hevc.c
	libavcodec/iff.c
	libavcodec/imc.c
	libavcodec/libopenjpegdec.c
	libavcodec/libvo-aacenc.c
	libavcodec/libvorbisenc.c
	libavcodec/libvpxdec.c
	libavcodec/libvpxenc.c
	libavcodec/libx264.c
	libavcodec/mjpegbdec.c
	libavcodec/mjpegdec.c
	libavcodec/mpegaudiodec_float.c
	libavcodec/msmpeg4dec.c
	libavcodec/mxpegdec.c
	libavcodec/nvenc_h264.c
	libavcodec/nvenc_hevc.c
	libavcodec/pngdec.c
	libavcodec/qpeg.c
	libavcodec/ra288.c
	libavcodec/rv10.c
	libavcodec/s302m.c
	libavcodec/sp5xdec.c
	libavcodec/takdec.c
	libavcodec/tiff.c
	libavcodec/tta.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/vp6.c
	libavcodec/vp9.c
	libavcodec/wavpack.c
	libavcodec/yop.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-27 22:50:18 +02:00
Michael Niedermayer
1c5b712c0a avcodec/diracdec: Check for hpel_base allocation failure
Fixes null pointer dereference
Fixes: signal_sigsegv_b02a96_280_RL_420p_ffdirac.drc with memlimit of 67108864

Found-by: Samuel Groß, Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-18 18:05:41 +02:00
Michael Niedermayer
8f1afde11d avcodec/diracdec: Make data_unit_size unsigned
Fixes CID1271788

with this change the value is more explicitly checked, it was fully checked
before though

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-14 23:18:49 +02:00
Michael Niedermayer
9253cc496a avcodec/diracdec: Replace default_bsep[] by multiplication
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-07 05:07:55 +02:00
Andreas Cadhalpun
75fc81c831 diracdec: check that block length is valid
In init_planes p->xblen and p->yblen are set to:
            p->xblen = s->plane[0].xblen >> s->chroma_x_shift;
            p->yblen = s->plane[0].yblen >> s->chroma_y_shift;

These are later used as block_w and block_h arguments of
s->vdsp.emulated_edge_mc. If one of them is 0 it triggers an av_assert2
in emulated_edge_mc:
    av_assert2(start_x < end_x && block_w > 0);
    av_assert2(start_y < end_y && block_h > 0);

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-06 18:02:35 +02:00
Andreas Cadhalpun
4b13a542a2 dirac: use and forward error codes
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-06 17:50:09 +02:00
Michael Niedermayer
a2190de52d avcodec/diracdec: Fix types and wraparounds in dirac_decode_picture_header()
previously various variables had a too small type to support the required 32bit unsigned
range allowed from the spec

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-06 02:44:21 +02:00