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

232 Commits

Author SHA1 Message Date
Marth64
96ed043afa
avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD
Signed-off-by: Marth64 <marth64@proxyid.net>
2023-03-02 13:45:59 +01:00
Paul B Mahol
fc9a3b584d avcodec/mlpdec: parse and use substream info bits 2023-01-31 18:45:22 +01:00
Michael Niedermayer
aa79560de5
avcodec/mlpdec: Check max matrix instead of max channel in noise check
This is a regression since: adaa06581c
Before this, max_channel and  max_matrix_channel where compared for equality

Fixes: out of array access
Fixes: 53340/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-514959011885875

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-11-28 20:58:05 +01:00
Michael Niedermayer
f1f78e3cf4
avcodec/mlpdec: add max channels check
Fixes: out of array access
Fixes: 51648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-4644322217164800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-04 23:47:54 +02:00
Paul B Mahol
2069894bc1 avcodec/mlpdec: unbreak TrueHD single substream mono decoding 2022-09-18 15:13:37 +02:00
Paul B Mahol
adaa06581c avcodec/mlpdec: relax channels checking
Internal TrueHD decoder channel rematrix can mix 2 stereo substreams
into single mono stream.

Fixes #1726
2022-09-18 15:13:36 +02:00
Paul B Mahol
e35af6bcef avcodec/mlpdec: fix decoding of overlapping channels in substreams
Fixes #5039
2022-09-17 10:26:20 +02:00
Andreas Rheinhardt
48286d4d98 avcodec/codec_internal: Add macro to set AVCodec.long_name
It reduces typing: Before this patch, there were 105 codecs
whose long_name-definition exceeded the 80 char line length
limit. Now there are only nine of them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:42:57 +02:00
Andreas Rheinhardt
d1a5ef4069 avcodec/internal: Move ff_side_data_update_matrix_encoding to decode.h
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-27 14:14:57 +02:00
Andreas Rheinhardt
66b691f99f avcodec/internal: Move ff_get_buffer() to decode.h
Only used by decoders (encoders have ff_encode_alloc_frame()).

Also clean up the other headers a bit while removing now redundant
internal.h inclusions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-27 14:14:56 +02:00
Andreas Rheinhardt
21b23ceab3 avcodec: Make init-threadsafety the default
and remove FF_CODEC_CAP_INIT_THREADSAFE
All our native codecs are already init-threadsafe
(only wrappers for external libraries and hwaccels
are typically not marked as init-threadsafe yet),
so it is only natural for this to also be the default state.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-18 20:04:59 +02:00
Andreas Rheinhardt
2d764069be avcodec/vlc: Use structure instead of VLC_TYPE array as VLC element
In C, qualifiers for arrays are broken:
const VLC_TYPE (*foo)[2] is a pointer to an array of two const VLC_TYPE
elements and unfortunately this is not compatible with a pointer
to a const array of two VLC_TYPE, because the latter does not exist
as array types are never qualified (the qualifier applies to the base
type instead). This is the reason why get_vlc2() doesn't accept
a const VLC table despite not modifying the table at all, as
there is no automatic conversion from VLC_TYPE (*)[2] to
const VLC_TYPE (*)[2].

Fix this by using a structure VLCElem for the VLC table.
This also has the advantage of making it clear which
element is which.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-17 16:47:29 +02:00
Andreas Rheinhardt
4243da4ff4 avcodec/codec_internal: Use union for FFCodec decode/encode callbacks
This is possible, because every given FFCodec has to implement
exactly one of these. Doing so decreases sizeof(FFCodec) and
therefore decreases the size of the binary.
Notice that in case of position-independent code the decrease
is in .data.rel.ro, so that this translates to decreased
memory consumption.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 20:02:37 +02:00
Andreas Rheinhardt
ce7dbd0481 avcodec/codec_internal: Make FFCodec.decode use AVFrame*
This increases type-safety by avoiding conversions from/through void*.
It also avoids the boilerplate "AVFrame *frame = data;" line
for non-subtitle decoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 19:54:09 +02:00
Michael Niedermayer
23e27a360e avcodec/mlpdec: Use 64bit for channel layout
Fixes: shift exponent 33 is too large for 32-bit type 'int'
Fixes: 45645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5651350182035456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-21 09:07:58 +01:00
Andreas Rheinhardt
20f9727018 avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec
Up until now, codec.h contains both public and private parts
of AVCodec. This exposes the internals of AVCodec to users
and leads them into the temptation of actually using them
and forces us to forward-declare structures and types that
users can't use at all.

This commit changes this by adding a new structure FFCodec to
codec_internal.h that extends AVCodec, i.e. contains the public
AVCodec as first member; the private fields of AVCodec are moved
to this structure, leaving codec.h clean.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-21 01:33:09 +01:00
Andreas Rheinhardt
a688f3c13c avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.h
Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault.
This reduces the amount of files that have to include internal.h
(which comes with quite a lot of indirect inclusions), as e.g.
most encoders don't need it. It is furthemore in preparation
for moving the private part of AVCodec out of the public codec.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-21 01:33:09 +01:00
Martin Storsjö
a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
This avoids unnecessary rebuilds of most source files if only the
list of enabled components has changed, but not the other properties
of the build, set in config.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:49 +02:00
Anton Khirnov
d4b79b2e32 mlp: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:43 -03:00
Paul B Mahol
a8a7c5d502 avcodec/thd: fix special stereo support 2021-12-18 10:20:24 +01:00
Paul B Mahol
946493eb3e avcodec/mlpdec: cover case when >2 channels are in single substream
Previously it was assumed that all >2 channels streams have >1 substreams.
2021-11-11 21:54:32 +01:00
Paul B Mahol
17130321f3 avcodec/mlpdec: skip decoding substreams if their channels are not to be used 2021-10-03 11:46:53 +02:00
Paul B Mahol
114634a51a avcodec/mlpdec: update matrix encoding only if it changed 2021-10-03 11:46:53 +02:00
Paul B Mahol
57f0b36367 avcodec/mlpdec: fix decoding single stereo stream in TrueHD 2021-09-23 23:43:48 +02:00
Paul B Mahol
5d92b73c64 avcodec/mlpdec: fix integer sanitizer warning under clang
Fixes:
libavcodec/mlpdec.c:1108:37: runtime error: negation of 1 cannot be represented in type 'unsigned int'
2021-09-07 18:16:13 +02:00
Paul B Mahol
0c87b43c6c avcodec/mlp: move sync defines to common header 2021-09-05 18:12:56 +02:00
Paul B Mahol
034133a0df avcodec/mlpdec: reset lossless crc checking when stream ends
Fixes invalid reports of bad lossless crc.
While here make end of stream message into debug level as it is
not really important to user.
Also wait for new major sync frame as invalid concating of files
may produce invalid files, which cause various errors.
2021-08-31 21:22:17 +02:00
Paul B Mahol
5673a48425 avcodec/mlpdec: add flush support
Fixes spurious lossless check failures when seeking.
2021-08-29 00:09:29 +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
Anton Khirnov
e15371061d lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump
They are not properly namespaced and not intended for public use.
2021-01-01 14:14:57 +01:00
Hendrik Leppkes
494f868e93 avcodec: set AV_CODEC_CAP_CHANNEL_CONF on decoders which set their own channels
The decoders in this set either have a fixed channel count, or read it
from the bitstream, and thus do not require the channel count as
external information.

Fixes various regressions since
81503ac58a, which requires a valid channel
count for decoders which do not set this capability.

Signed-off-by: Hendrik Leppkes <h.leppkes@gmail.com>
2020-12-10 13:28:35 +01:00
Andreas Rheinhardt
08a992e018 avcodec/mlpdec: Avoid code duplication when initializing VLCs
Reviewed-by: Jai Luthra <me@jailuthra.in>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-24 11:35:04 +01:00
Andreas Rheinhardt
34aa85cd91 avcodec/mlpdec: Make decoders init-threadsafe
Reviewed-by: Jai Luthra <me@jailuthra.in>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-24 11:35:04 +01:00
Jai Luthra
4566cfed9c avcodec/mlpdec: use get_bits_long for huff lsbs
lsb bits may go beyond 25 bits, so to be safe use get_bits_long

Signed-off-by: Jai Luthra <me@jailuthra.in>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-08 18:20:43 +01:00
Jai Luthra
49cfbedb9d mlp: check huff_lsbs only when codebook is used
When no codebook is used, huff_lsbs can be more than 24 and still decode to
original values once filters are applied.

Signed-off-by: Jai Luthra <me@jailuthra.in>
2020-02-04 11:19:12 +01:00
James Almer
109b0d7c0f avcodec/mlp_parser: split off shared code to its own file
Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-07 17:30:19 -03:00
Michael Niedermayer
fc32e08941 avcodec/mlpdec: Insuffient typo
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-23 22:48:35 +01:00
Michael Niedermayer
63c4a4b0d6 avcodec/mlpdec: Only change noise_type if the related fields are valid
Fixes: inconsistency
Fixes:runtime error: index 8 out of bounds for type 'int32_t [8]'
Fixes: 6686/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-5191383498358784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-05-26 00:54:55 +02:00
James Almer
34542ac033 Merge commit '970c76f32283bddf3a5afd24fe52db7a96186244'
* commit '970c76f32283bddf3a5afd24fe52db7a96186244':
  mlp_parser: Drop in-parser downmix functionality

Merged-by: James Almer <jamrial@gmail.com>
2017-10-30 17:20:45 -03:00
James Almer
e3ebc293c6 Merge commit '94c54d97e7f4fe90570c323803f2bdf6246c1010'
* commit '94c54d97e7f4fe90570c323803f2bdf6246c1010':
  mlp: Factor out channel layout subset checks

Merged-by: James Almer <jamrial@gmail.com>
2017-10-30 16:52:36 -03:00
James Almer
8b63acaeee Merge commit '1f6e5dd4d4dd9c02371ad211049d27edb6d95286'
* commit '1f6e5dd4d4dd9c02371ad211049d27edb6d95286':
  mlp: Rename the channel layout variable

Merged-by: James Almer <jamrial@gmail.com>
2017-10-30 16:40:11 -03:00
Michael Niedermayer
361e0310d9 avcodec/mlpdec: Check quant_step_size against huff_lsbs
This reorders the operations so as to avoid computations with the above arguments
before they have been initialized.
Fixes part of 1708/clusterfuzz-testcase-minimized-5035111957397504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-03 23:30:31 +02:00
Michael Niedermayer
ac8dfcbd89 avcodec/mlpdec: Do not leave invalid values in matrix_out_ch[] on error
Fixes: runtime error: index 12 out of bounds for type 'uint8_t [8]'
Fixes: 1832/clusterfuzz-testcase-minimized-6574546079449088

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-27 14:37:42 +02:00
Michael Niedermayer
42e42af76c avcodec/mlpdec: Fix runtime error: shift exponent -5 is negative
Fixes part of 1708/clusterfuzz-testcase-minimized-5035111957397504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-22 19:42:39 +02:00
Michael Niedermayer
64ea4d102a avcodec/mlpdec: Do not leave a invalid num_primitive_matrices in the context
Fixes: runtime error: index 8 out of bounds for type 'uint8_t [8]'
Fixes: 1699/clusterfuzz-testcase-minimized-6327177438035968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-20 01:24:11 +02:00
Michael Niedermayer
25c81e4b73 avcodec/mlpdec: Fix: runtime error: left shift of negative value -8
Fixes: 1658/clusterfuzz-testcase-minimized-4889937130291200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-18 04:08:31 +02:00
Michael Niedermayer
552adf1dd3 avcodec/mlpdec: Fix runtime error: left shift of negative value -1
Fixes: 1636/clusterfuzz-testcase-minimized-5310494757879808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-17 00:54:00 +02:00
Michael Niedermayer
e3e51f8c14 avcodec/mlpdec: Check that there is enough data for headers
Fixes: out of array access
Fixes: 1541/clusterfuzz-testcase-minimized-6403410590957568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-13 23:15:13 +02:00
Michael Niedermayer
74dc728a2c avcodec/mlp: Fix multiple runtime error: left shift of negative value -1
Fixes: 1512/clusterfuzz-testcase-minimized-4713846423945216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-13 15:54:33 +02:00
Michael Niedermayer
c535436cbe avcodec/mlpdec: Fix runtime error: left shift of negative value -22
Fixes: 1355/clusterfuzz-testcase-minimized-6662205472768000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-06 12:08:14 +02:00