1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-05 15:58:07 +02:00
Commit Graph

20 Commits

Author SHA1 Message Date
Andreas Rheinhardt
b05631f7b9 avcodec/speedhq, speedhqenc: Make codecs init-threadsafe
The SpeedHQ decoder uses and initializes a RLTable's VLC, yet it also
initializes other parts of the RLTable that it does not use. This has
downsides besides being wasteful: Because the SpeedHQ encoder also
initializes these additional fields, there is a potential for data races
(and therefore undefined behaviour). In fact, removing the superfluous
initializations from the decoder automatically makes both the decoder
and the encoder init-threadsafe. This commit does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-05-05 17:52:41 +02:00
Andreas Rheinhardt
a247ac640d avcodec: Constify AVCodecs
Given that the AVCodec.next pointer has now been removed, most of the
AVCodecs are not modified at all any more and can therefore be made
const (as this patch does); the only exceptions are the very few codecs
for external libraries that have a init_static_data callback.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:15 -03:00
Michael Niedermayer
462b8261aa avcodec/speedhq: Width < 8 is not supported
Fixes: out of array access
Fixes: 31733/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-4704307963363328
Fixes: 31736/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-6190960292790272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-19 23:59:45 +01:00
Paul B Mahol
433227d452 avcodec/speedhq: fix decoding non 444 subsampling when width is not multiple of 16 2021-03-04 19:09:56 +01:00
Anton Khirnov
c8c2dfbc37 lavu: move LOCAL_ALIGNED from internal.h to mem_internal.h
That is a more appropriate place for it.
2021-01-01 14:11:01 +01:00
Andreas Rheinhardt
eea2638e9a configure, libavcodec/speedhq: Fix compiling SpeedHQ encoder
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-31 12:06:04 +01:00
Andreas Rheinhardt
2b04405b63 avcodec/speedhq: Remove cast
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-12-31 11:54:22 +01:00
Jean-Baptiste Kempf
052a5993ad avcodec: add SpeedHQ encoder 2020-11-24 09:38:35 +01:00
Andreas Rheinhardt
3977aeb78c avcodec/speedhq: Avoid reversing BE codes for LE bitstream reader
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-12 22:35:40 +02:00
Andreas Rheinhardt
e78bbbc2b1 avcodec/speedhq: Don't use ff_ prefix for static symbols
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-12 22:18:44 +02:00
Andreas Rheinhardt
7b6acfa68f avcodec/speedhq: Don't pretend reading DC can fail
It can't, because the tables used don't have any loose ends. This also
fixes a bug in the only caller of decode_dc_le(): It didn't check the
return value.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-12 22:17:22 +02:00
Jean-Baptiste Kempf
fc3f5cd149 Speedhq: Decode field 2 correctly
This is similar to field 1 (effd2e72)
2020-07-06 18:23:50 +01:00
Michael Niedermayer
fd3eda4030 avcodec/speedhq: Make speedhq_vlc const
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-10-07 03:03:09 +02:00
Martin Vignali
cbbec68847 libavcodec/blockdsp : add AVX version
Also modify the required alignment, to 32 instead of 16
for several codecs

Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-03 19:47:37 -03:00
Steinar H. Gunderson
effd2e7291 speedhq: fix behavior of single-field decoding
The height convention for decoding frames with only a single field made sense
for compatibility with legacy decoders, but doesn't really match the convention
used by NDI, which is the primary (only?) user. Thus, change it to simply
assuming that if the two fields overlap, the frame is meant to be a single
field and the frame height matches the field height.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-08-03 16:36:02 -03:00
Steinar H. Gunderson
e3c14eaa54 speedhq: fix decoding artifacts
The quantization table is stored in the natural order, but when we
access it, we use an index that's in zigzag order, causing us to read
the wrong value. This causes artifacts, especially in areas with
horizontal or vertical edges. The artifacts look a lot like the
DCT ringing artifacts you'd expect to see from a low-bitrate file,
but when comparing to NewTek's own decoder, it's obvious they're not
supposed to be there.

Fix by simply storing the scaled quantization table in zigzag order.
Performance is unchanged.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-02-21 00:40:20 +01:00
Steinar H. Gunderson
08b098169b speedhq: fix out-of-bounds write
Certain alpha run lengths (for SHQ1/SHQ3/SHQ5) could be stored in
both long and short versions, and we would only accept the short version,
returning -1 (invalid code) for the others. This could cause an
out-of-bounds write on malicious input, as discovered by
Andreas Cadhalpun during fuzzing.

Fix by simply allowing both versions, leaving no invalid codes
in the alpha VLC.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2017-02-02 01:12:07 +01:00
Michael Niedermayer
1df3d636d4 avcodec/speedhq: Fix warning about "initialization from incompatible pointer type"
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-01-19 19:49:55 +01:00
Steinar H. Gunderson
d68d7198be speedhq: Align blocks variable properly.
Seemingly ff_clear_block_sse assumed that the block array is aligned,
so make sure it is.

Fixes ticket #6079

Signed-off-by: James Almer <jamrial@gmail.com>
2017-01-13 16:47:53 -03:00
Steinar H. Gunderson
2a293ec7ac avcodec: add Newtek SpeedHQ decoder
This decoder can decode all existing SpeedHQ formats (SHQ0–5, 7, and 9),
including correct decoding of the alpha channel.

1080p is decoded in 142 fps on one core of my i7-4600U (2.1 GHz Haswell),
about evenly split between bitstream reader and IDCT. There is currently
no attempt at slice or frame threading, even though the format trivially
supports both.

NewTek very helpfully provided a full set of SHQ samples, as well as
source code for an SHQ2 encoder (not included) and assistance with
understanding some details of the format.
2017-01-11 16:02:10 +01:00