1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-18 03:19:31 +02:00
Commit Graph

108797 Commits

Author SHA1 Message Date
Andreas Rheinhardt
4e26bd7ad7 avcodec/h261enc: Store the H.261 format value
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-06 15:00:21 +02:00
Andreas Rheinhardt
d74ca6fdb4 avcodec/mpegvideo_enc: Move H.261 size check to h261enc.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-06 15:00:21 +02:00
Andreas Rheinhardt
759d216c47 avcodec/mpegvideo_enc: Call ff_h261_encode_init() earlier
It does not require anything that is being set between
the new position where it is called and the old position
where it used to be called; and nothing that it sets
gets overwritten between these two positions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-06 15:00:21 +02:00
Andreas Rheinhardt
40e4ddf619 avcodec/mpegvideo_enc: Move SpeedHQ check to speedhqenc.c
Also set this only once and not for every frame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-06 15:00:21 +02:00
Andreas Rheinhardt
406c7fceeb fate/vcodec: Add speedhq tests
The vsynth3 tests are disabled, because the encoder produces garbage.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-06 15:00:21 +02:00
Gavin Smith
2c2aaa5bd0 avformat/mxfdec: do not log warning of multiple ANC packets if count is 0
Some NLVEs may insert a KLV packet for EIA-608 data even though
the number of encapsulated ANC packets is zero.
2022-10-06 10:23:39 +02:00
Richard Ayres
b074424bf6 Encrypted SMPTE DC MXF - additional UL needed to unpack EKLV packet
Thanks, Pierre-Anthony. I've updated the patch to remove the unnecessary UL and it's now using mxf_match_uid() to detect the EKLV packet.

Signed-off-by: Richard Ayres <richard.ayres@bydeluxe.com>
2022-10-06 10:04:17 +02:00
Andreas Rheinhardt
451b310d4f avcodec/fraps: Fix segfault with negative linesizes
Using unsigned and negative linesizes doesn't really work.
Use ptrdiff_t instead. This fixes the fraps-v0 and fraps-v1
FATE tests with negative linesizes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:39:10 +02:00
Andreas Rheinhardt
fcfa6965e5 avcodec/escape124: Fix segfault with negative linesizes
Use ptrdiff_t instead of unsigned for linesizes.
Fixes the armovie-escape124 FATE test with negative linesizes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:38:52 +02:00
Andreas Rheinhardt
fced3a17db avcodec/c93: Fix segfault when using negative linesizes
c93.c used an int for the stride and an unsigned for the current
linenumber. This does not work when using negative linesizes.
So use ptrdiff_t for stride and int for linenumber.

This fixes the cyberia-c93 FATE test when using negative linesizes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:38:52 +02:00
Andreas Rheinhardt
ce4713ea73 avcodec/sgidec: Use planar pixel formats
The data in SGI images is stored planar, so exporting
it via planar pixel formats is natural.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:38:51 +02:00
Andreas Rheinhardt
e771223ec1 avcodec/sgidec: Avoid redundant private context
SGI is intra-frame only; the decoder therefore does not
maintain any state between frames, so remove
the private context.

Also rename depth to nb_components.

Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:38:31 +02:00
Andreas Rheinhardt
54cf0482bd avcodec/sgidec: Support negative linesizes
The earlier code used "p->data[0] + p->linesize[0] * s->height" with
the latter being unsigned, which gives the wrong value for negative
linesizes. There is also a not so obvious problem with this:
In case of negative linesizes, the last line is the start of
the allocated buffer, so using the line after the last line
would involve undefined pointer arithmetic. So don't do it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:38:11 +02:00
Andreas Rheinhardt
02c19dfb85 avcodec/sunrast: Use ptrdiff_t for stride
Fixes segfaults with negative linesizes; in particular,
this affected the sunraster-(1|8|24)bit-(raw|rle) and
sunraster-8bit_gray-raw FATE tests.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:37:52 +02:00
Andreas Rheinhardt
8a9eac7e42 avcodec/asv: Split ASV1Context into decoder and encoder contexts
A lot of the stuff in ASV1Context is actually only used
by decoders or encoders, but not both: Of the seven contexts
in ASV1Context, only the BswapDSPContext is used by both.
So splitting makes sense.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 14:20:33 +02:00
Lynne
bd3e552549
lavu: bump minor and add APIChanges entry for RISC-V's RVBbasic 2022-10-05 08:31:15 +02:00
Rémi Denis-Courmont
2abafd7307 lavc/bswapdsp: RISC-V V bswap16_buf 2022-10-05 08:26:19 +02:00
Rémi Denis-Courmont
d7528af4df lavc/bswapdsp: RISC-V V bswap_buf 2022-10-05 08:26:19 +02:00
Rémi Denis-Courmont
f0ef11ea83 lavc/bswapdsp: RISC-V B bswap_buf
Simply taking the Zbb REV8 instruction into use in a simple loop gives
some significant savings:

bswap_buf_c: 1081.0
bswap_buf_rvb_b: 771.0

But we can also use the 64-bit REV8 as a pseudo-SIMD instruction with
just one additional shift, and one fewer load, effectively doubling the
bandwidth. Consequently, this patch is useful even if the compile-time
target has Zbb enabled for C code:

bswap_buf_c: 1081.0
bswap_buf_rvb_b: 341.0  (this patch)

On the other hand, this approach fails miserably for bswap16_buf as the
ratio of shifts and stores becomes unfavorable compared to naïve C:

bswap16_buf_c: 1542.0
bswap16_buf_rvb_b: 1803.7

Unrolling to process 128 bits (4 samples) at a time actually worsens
performance ever so slightly:

bswap_buf_c: 1081.0
bswap_buf_rvb_b: 408.5
2022-10-05 08:26:19 +02:00
Rémi Denis-Courmont
37d5ddc317 lavu/riscv: CPU flag for the Zbb extension
Unfortunately, it is common, and will remain so, that the Bit
manipulations are not enabled at compilation time. This is an official
policy for Debian ports in general (though they do not support RISC-V
officially as of yet) to stick to the minimal target baseline, which
does not include the B extension or even its Zbb subset.

For inline helpers (CPOP, REV8), compiler builtins (CTZ, CLZ) or
even plain C code (MIN, MAX, MINU, MAXU), run-time detection seems
impractical. But at least it can work for the byte-swap DSP functions.
2022-10-05 08:26:19 +02:00
Lynne
b25c6a5704
riscv/alacdsp: drop config.h include 2022-10-05 06:59:43 +02:00
Rémi Denis-Courmont
3ba5579e55 riscv: remove unnecessary #include's
Pointed out by Andreas Rheinhardt.
2022-10-05 06:54:56 +02:00
Rémi Denis-Courmont
f0d1637c11 lavc/alacdsp: RISC-V V append_extra_bits[1] 2022-10-05 06:51:11 +02:00
Rémi Denis-Courmont
55bde97f29 lavc/alacdsp: RISC-V V append_extra_bits[0] 2022-10-05 06:51:11 +02:00
Rémi Denis-Courmont
64ab577954 lavc/alacdsp: RISC-V V decorrelate_stereo
To avoid data dependencies, this does the following unroll, which
requires one extra but probably free addition:

    coeff = (b * left_weight) >> decorr_shift;
    b += a;
    a -= coeff;
    b -= coeff;
    swap(a, b);
2022-10-05 06:51:11 +02:00
Andreas Rheinhardt
23411e6dcd avcodec/sbcdec: Remove always-false check
We never guard against a user freeing/stealing the private context;
and returning AVERROR(EIO) is inappropriate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:15:59 +02:00
Andreas Rheinhardt
91e192c3a0 avcodec/opus: Move Silk declarations to a new header, opus_silk.h
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:15:43 +02:00
Andreas Rheinhardt
c095358289 avcodec/opus: Move defines to better places
Move ROUND_MUL* macros to their only users and the Celt
macros to opus_celt.h. Also improve the other headers
a bit while at it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:15:43 +02:00
Andreas Rheinhardt
81b927a53b avcodec/opus: Move remaining celt declarations to opus_celt.h
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:15:04 +02:00
Andreas Rheinhardt
542c334eb5 avcodec/opus_celt, opus_pvq: Move CeltPVQ typedef to opus_pvq.h
It is more natural that way.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:08:39 +02:00
Andreas Rheinhardt
a622f4451f avcodec/opus_celt: Break cyclic inlusion of opus_celt.h<->opus_pvq.h
Simply don't include opus_pvq.h in opus_celt.h: The latter only
uses pointers to CeltPVQ.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:08:16 +02:00
Andreas Rheinhardt
4fc2531fff avcodec/opus: Move stuff shared by decoder and parser to a new file
opus.h (which is used by all the Opus code) currently includes
several structures only used by the parser and the decoder;
several elements of OpusContext are even only used by the decoder.

This commit therefore moves the part of OpusContext that is shared
between these two components (and used by ff_opus_parse_extradata())
out into a new structure and moves all the other accompanying
structures and functions to a new header, opus_parse.h; the
functions itself are also moved to a new file, opus_parse.c.
(This also allows to remove several spurious dependencies
of the Opus parser and encoder.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:04:41 +02:00
Andreas Rheinhardt
6658028482 avcodec/opus: Move OpusStreamContext to its only user
Namely opusdec.c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:02:41 +02: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
Michael Niedermayer
77164b2344
avcodec/speexdec: Check channels > 2
More than 2 channels seems unsupported, the code seems to just output empty extra channels

Fixes: Timeout
Fixes: 51569/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-5511509165342720

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
Michael Niedermayer
5f44489cc5
avformat/vividas: Check packet size
Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int'
Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328

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
Michael Niedermayer
c5f61c99f9
tests/fate/truehd: Add test for shortened Ticket1726 testcase
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-04 23:47:53 +02:00
Andreas Rheinhardt
042c1966da avcodec/pngdec: Don't use unsigned for width, height
Otherwise p->linesize[0] * y will be evaluated as an unsigned
which leads to segfaults in case linesize is negative.
This happens in the apng-dispose-previous FATE-test in case
one makes get_buffer return pictures with negative linesizes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:03 +02:00
Andreas Rheinhardt
04196852a2 avcodec/mpegvideo_dec: Fix UB NULL + 0
Affected the mpeg2-field-enc FATE-test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:03 +02:00
Andreas Rheinhardt
63b3156558 avformat/aviobuf: Don't use NULL as src for memcpy
This might happen in avio_write() if size == 0
when the direct codepath is taken. It is undefined behaviour
according to the spec although it happens to work in practice.
Fixes the webm-webvtt-remux FATE-test under UBSan.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
e95fdf7660 avcodec/g723_1enc: Fix undefined left-shifts of negative numbers
Affected the acodec-g723_1 FATE-test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
e47f3e366b avcodec/g723_1enc: Remove unnecessary av_clipl_int32()
partial_corr is an int16_t and so the av_clipl_int32()
never clips and can be removed. This also avoids
undefined left-shifts of negative numbers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
1e1ddbb70d avcodec/zerocodec: Avoid undefined NULL - 0
Fixes the zerocodec FATE-test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
bf8e40ae0d avcodec/wmalosslessdec: Simplify flushing, avoid NULL + 0
Return immediately if not enough leftover bits are available
when flushing. This is simpler and also avoids an
init_get_bits(gb, NULL, 0) (which currently leads to NULL + 0,
which is UB; this affects the lossless-wma(|-1|-2|-rawtile)
FATE tests).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
44bdb4efd0 avcodec/wmavoice: Check init_get_bits8()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
d5eb74b58d avcodec/wmavoice: Don't initialize GetBitContext with buf == NULL
Happens when flushing. This triggers NULL + 0 (which is UB) in
init_get_bits_xe (which previously errored out, but the return value
has not been checked) and in copy_bits().

This fixes the wmavoice-(7|11|19)k FATE-tests with UBSan.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
8a61f66381 avocdec/cavsdsp: Fix undefined pointer arithmetic
src2 is used in CAVS_SUBPIX_HV iff FULL is true (it is exactly
for the egpr functions); otherwise it might be NULL. So check
for FULL before doing pointer arithmetic.
Fixes a "src/libavcodec/cavsdsp.c:524:1: runtime error: applying
non-zero offset 8 to null pointer" from UBSan.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
22e7e4e19d avcodec/vc2enc_dwt: Fix left shifts of negative numbers
Fixes the vsynth(1|2|_lena)-vc2-(thaar|t5_3) FATE tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:01:01 +02:00
Andreas Rheinhardt
3b09e8f5e9 avcodec/jpeg2000dsp: Use unsigned to avoid overflow
Affected the jpeg2000dsp checkasm test.

Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 18:00:43 +02:00
Andreas Rheinhardt
2fd99aa208 avcodec/mpeg12: Move ff_mpeg1_clean_buffers decl to a new header
It allows to avoid including mpegvideo.h when including mpeg12.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-04 17:41:34 +02:00