1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2026-04-24 04:44:54 +02:00
Commit Graph

122672 Commits

Author SHA1 Message Date
Niklas Haas ca2c5ff412 avformat/http: parse range size from Content-Range header
In the event that the range returned is smaller than the true filesize, we
should only expect to receive that many bytes - not the entire rest of the
file.

This commit is theoretically non-functional on its own, since any conforming
HTTP server will always return us the full file range, but I wanted to split
it off from the subsequent changes in order to make review easier.
2026-02-07 10:02:36 +00:00
Niklas Haas 19cae9151c avformat/http: print error on HTTP response failure
This currently fails silently with zero indication of what the problem might
be, which tripped me up a bit while debugging.
2026-02-07 10:02:36 +00:00
Niklas Haas 5f95a1e714 avformat/http: fix noop seek check
This fails to consider the case of whence == SEEK_END and the resulting
offset happening to exactly match the current position.

Reorder the check to compute the target position first, then compare.
2026-02-07 10:02:36 +00:00
Brad Smith c352a9ab02 avutil/cpu: add CPU feature detection for AArch64 CRC32 on OpenBSD
Signed-off-by: Brad Smith <brad@comstyle.com>
2026-02-06 14:24:01 -05:00
Andreas Rheinhardt 0fefecd53f Revert "avcodec/opus/parse: export the packet and extradata parsing functions"
This reverts commit aa20d7b3e8.

Adding these avpriv functions is absolutely overblown: Muxers
can get the desired duration in a few lines themselves.
In particular, using the parse functions from this file
necessitated parsing the extradata (and entailed exporting
the parsing function), although it was only used to know
whether the frames are self-delimiting, but everything of
interest to a muxer does not depend on this at all.

The commit to be reverted also made several structures
part of the ABI, which should be avoided in general.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:09:15 +01:00
Andreas Rheinhardt 12747e6296 avformat/matroskaenc: Parse Opus packet durations ourselves
This avoids avpriv functions from lavc/opus/parse.c
(which parse way more than we need, necessitating
parsing the extradata).
It furthermore makes the output of the muxer consistent,
i.e. no longer depending upon whether the Opus parser
or decoder are enabled (the avpriv functions would just
return AVERROR(ENOSYS)).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:05:14 +01:00
Andreas Rheinhardt 853843d86f avcodec/opus/parse: Move frame_duration tab into a file of its own
This is in preparation for duplicating it into libavformat.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:04:50 +01:00
James Almer 3ab8b976c1 avformat/matroskaenc: parse Opus packets to write proper durations
Before this patch, the last packet in the affected fate test would be written
without a BlockDuration element despite the packet's duration being shorter
than the Opus frame size.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer aa20d7b3e8 avcodec/opus/parse: export the packet and extradata parsing functions
Needed for the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 11e9a325ec tests/fate/matroska: remove copyts from audio tests
It's not needed after the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 0880458e4c avformat/matroskadec: take into account priming samples in audio tracks
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 1dd8547193 avformat/demux: don't overwrite already set packet durations with parser ones
Following up on b613eebe78, if a demuxer that exports complete frames sets a
duration, don't overwrite it from the output of the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
Michael Niedermayer 8f57b04fe5 avcodec/hevc/sei: Use get_bits64() in decode_nal_sei_3d_reference_displays_info()
Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:426
Fixes: 468435217/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4644127078940672

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 20:20:08 +00:00
Michael Niedermayer f112ae503e avformat/hls: Check for integer overflow with #EXTINF:
Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:59:29 +00:00
Michael Niedermayer af86f0ffcc avcodec/dca_xll: Clear padding in ff_dca_xll_parse()
Fixes: Use of uninitialized memory
Fixes: 472020020/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_DEC_fuzzer-6433045331902464

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:12:46 +01:00
Michael Niedermayer 00b4d67812 avformat/demux: Allow non opened codec in has_decode_delay_been_guessed()
Fixes: assertion failure
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Michael Niedermayer 5fa7d588f5 avformat/flvdec: Check need_context_update when audio codec changes
We did check video codecs but not audio
Fixes: Assertion failure (on codec_id) in parser.c
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Michael Niedermayer c6c6874c44 avfilter/vf_find_rect: Check x/y min/max
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
Michael Niedermayer 12321e5eba vfilter/vf_find_rect: Clamp x/y min/max to valid values
Fixes: #YWH-PGM40646-15
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
Michael Niedermayer ee7a15f0a2 tools/target_dec_fuzzer: adjust threshold for MAGICYUV
Fixes: Timeout
Fixes: 471975516/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-5987279668838400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:50:26 +01:00
Michael Niedermayer 189bc0aaf5 avcodec/dxv: Clear tex_data padding on reallocation
dxv assumes that newly reallocated memory in tex_data is not uninitialized
thus we have to do that too in case of reallocation in ff_lzf_uncompress()

Fixes: 475000819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5571269310611456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:29:08 +01:00
Michael Niedermayer 0f35146e27 avcodec/lzf: Remove size messing from ff_lzf_uncompress()
size represents the output size
randomly changing it but not reseting it on errors leaks uninitialized memory.

Fixes: 475000819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5571269310611456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:29:08 +01:00
Michael Niedermayer 5db50e8775 avcodec/ffv1enc: refine end condition
In the case where the last sorted value was -1u and we where on the first
pass of run1 we failed to fill the last few values of bitmap

No real world testcase is known

Fixes: use of uninitialized memory
Fixes: 460333808/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-6370167888347136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:07:13 +01:00
Michael Niedermayer 11a5afea31 avcodec/dca_xll: Check get_rice_array()
Fixes: use of uninitialized memory
Fixes: 451655450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_DEC_fuzzer-6527248623796224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 14:37:59 +01:00
Zane van Iperen b628cafd48 libavformat/argo_brp: fix incorrect ASF chunk header read
Was inadvertently broken in the switch to ffio_read_size().

Fixes: 6dd83fab44

PR: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21650

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2026-02-05 22:19:48 +10:00
Anthony Bajoua 627da1111c libavformat/movenc: Uses dynamic buffers for fragmented chunks 2026-02-04 18:45:15 -08:00
Jun Zhao 27dd2f1c70 lavc/hevc: fix missing # in ldrsw immediate offset
The ldrsw instruction requires immediate offset with # prefix.
This fixes the syntax error introduced in commit 26752368f0
(aarch64/h26x: Add put_hevc_pel_bi_w_pixels) where the
load_bi_w_pixels_param macro was added.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-05 09:13:22 +08:00
WyattBlue e48eaa8c62 avfilter/af_whisper: Add max_len parameter 2026-02-04 21:26:02 +00:00
Marton Balint 75f5d79f6a fftools/ffprobe: add base64 data dump format
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint ca6f3f3c17 fftools/ffprobe: use an AVTextFormatOptions struct in AVTextFormatContext
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint b1f14cbd0e fftools/ffprobe: fatorize dumping hexdump as data dump
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint 30be62b711 fftools/ffprobe: print AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL id and data
Data is only printed if -show_data is used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Michael Niedermayer d1a43f1486 avutil/dovi_meta: Document valid range for index of av_dovi_get_ext()
Every use case in libavcodec already checks the index

Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 15:25:18 +00:00
Andreas Rheinhardt 462fac0e0f tests/checkasm/vc1dsp: Use correct function argument
Fixes a stack-buffer overflow (detected by ASAN) when benching
vc1dsp.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-04 13:28:49 +01:00
Zhao Zhili e250854ecf aarch64/h264pred: disable inefficient functions
These assembly optimizations have been identified as "performance
regressions." Due to advancements in modern CPU micro-architectures
and compiler optimization the C implementations now consistently
outperform these handwritten routines.

Test Name          	 A55-clang       M1             A76-gcc-14      A510-clang      A715-clang      X3-clang
--------------------------------------------------------------------------------------------------------------------
pred8x8_dc_8_neon        55.9 ( 0.79x)!  0.2 ( 0.31x)!  35.7 ( 0.63x)!  98.3 ( 0.37x)!  35.9 ( 0.45x)!  33.6 ( 0.38x)!
pred8x8_dc_10_neon       57.0 ( 1.04x)   0.3 ( 0.36x)!  35.9 ( 0.94x)!  98.2 ( 0.53x)!  35.8 ( 0.58x)!  33.2 ( 0.50x)!
pred8x8_dc_128_8_neon    26.0 ( 0.69x)!  0.1 ( 0.43x)!  15.3 ( 0.73x)!  46.4 ( 0.36x)!  10.6 ( 0.48x)!  10.3 ( 1.09x)
pred8x8_dc_128_10_neon   25.3 ( 0.99x)!  0.1 ( 0.42x)!  19.3 ( 0.48x)!  44.5 ( 0.42x)!  10.0 ( 0.61x)!  11.0 ( 1.00x)
pred8x8_left_dc_8_neon   46.9 ( 0.72x)!  0.2 ( 0.26x)!  30.2 ( 0.49x)!  71.4 ( 0.39x)!  29.8 ( 0.35x)!  26.5 ( 0.44x)!
pred8x8_left_dc_10_neon  45.4 ( 0.82x)!  0.2 ( 0.29x)!  28.1 ( 0.67x)!  70.2 ( 0.47x)!  30.0 ( 0.38x)!  26.5 ( 0.43x)!
pred16x16_dc_8_neon      74.4 ( 1.34x)   0.3 ( 0.62x)!  44.7 ( 0.89x)!  128.0 ( 0.79x)! 48.5 ( 0.67x)!  39.4 ( 0.71x)!
pred16x16_dc_128_8_neon  37.9 ( 0.79x)!  0.1 ( 0.60x)!  20.1 ( 0.80x)!  41.8 ( 0.46x)!  16.2 ( 0.81x)!  12.8 ( 0.95x)!
pred16x16_left_dc_8_neon 69.9 ( 1.19x)   0.3 ( 0.46x)!  49.6 ( 0.54x)!  116.8 ( 0.62x)! 52.8 ( 0.45x)!  44.2 ( 0.51x)!
pred8x8_hori_8_neon      30.6 ( 1.39x)   0.1 ( 0.45x)!  19.4 ( 0.81x)!  71.0 ( 0.50x)!  15.9 ( 0.55x)!  12.2 ( 0.94x)!
pred8x8_hori_10_neon*    29.3 ( 1.82x)   0.1 ( 0.59x)!  18.5 ( 1.56x)   68.9 ( 0.64x)!  15.8 ( 0.62x)!  11.8 ( 0.97x)!
pred8x8_top_dc_8_neon    35.8 ( 0.96x)!  0.1 ( 0.59x)!  16.8 ( 0.81x)!  58.9 ( 0.44x)!  11.3 ( 0.89x)!  11.4 ( 0.99x)!
pred8x8_top_dc_10_neon   37.4 ( 1.24x)   0.1 ( 0.92x)!  20.4 ( 0.81x)!  59.5 ( 0.69x)!  10.5 ( 1.48x)   11.8 ( 1.02x)
pred8x8_vertical_8_neon  18.3 ( 1.08x)   0.1 ( 0.54x)!  12.8 ( 0.89x)!  37.2 ( 0.40x)!   8.3 ( 0.77x)!  11.2 ( 1.00x)
pred8x8_vertical_10_neon 19.0 ( 1.24x)   0.1 ( 0.55x)!  15.3 ( 0.62x)!  39.7 ( 0.50x)!   8.2 ( 0.91x)!  11.1 ( 0.99x)!

- pred8x8_horizontal_10 also underperforms on new architectures, but useful on A55 and A76.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 09:06:37 +00:00
Zhao Zhili f54841d375 avcodec/aarch64: add pngdsp
Test Name                    A55-gcc-11        M1-clang           A76-gcc-12          A510-clang        X3-clang
-------------------------------------------------------------------------------------------------------------------
add_bytes_l2_4096_neon        1807.2 ( 2.01x)    1.6 ( 1.94x)    333.0 ( 6.35x)   1058.2 ( 2.34x)    214.3 ( 1.99x)
add_paeth_prediction_3_neon  33036.1 ( 2.41x)  145.1 ( 1.66x)  20443.3 ( 1.97x)  35225.1 ( 1.23x)  19420.8 ( 1.05x)
add_paeth_prediction_4_neon  24368.6 ( 3.26x)  106.7 ( 2.01x)  15163.8 ( 2.77x)  26454.7 ( 1.62x)  14319.0 ( 1.35x)
add_paeth_prediction_6_neon  17900.6 ( 4.44x)   72.0 ( 2.70x)  10214.3 ( 4.20x)  18296.9 ( 2.27x)   9693.1 ( 1.97x)
add_paeth_prediction_8_neon  12615.4 ( 6.31x)   54.1 ( 2.58x)   7706.0 ( 5.45x)  13733.3 ( 2.94x)   7272.6 ( 2.63x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 12:05:35 +08:00
Zhao Zhili a0d4c07b86 tests/checkasm: add test for png
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 12:05:35 +08:00
Zhao Zhili 9ebfd68096 swscale/swscale: force SwsDither and SwsAlphaBlend to 32 bits
The 'sws_dither' and 'alphablend' options access 'SwsDither' and
'SwsAlphaBlend' enum fields as integers. This is unsafe when the
code is compiled with -fshort-enums, as the enum size might be
smaller than an int.

Since the 'dither' and 'alpha_blend' struct members are part of the
public API, their types cannot be easily changed.

To ensure safe integer access and maintain ABI compatibility across
different compiler settings, a MAX_ENUM value is added to force the
enums to a 32-bit underlying type.
2026-02-04 04:00:53 +00:00
Jack Lau 36b23092f9 avformat/rtsp: replace the deprecated localport with localrtpport
The `localport` already deprecated in 3a29702cb6

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-04 00:26:26 +00:00
Michael Niedermayer 1fd718c6a9 avformat/mpegts: Check program_info_length
Fixes: overread
No testcase

Found-by: Marton Balint
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Michael Niedermayer 5975149603 avformat/mpegts: Check IOD_DESCRIPTOR len
Fixes: out of array read
Fixes: VULN-7/poc.ts

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Jack Lau 5c6c12acb1 avformat/rtpenc: fix memleak when sdp create failed
Fix #20712

When print_sdp() fails during rtp streaming, sch_start()
returns error code without calling wirte_trailer, causing
a memory leak.

The avformat_free_context() will call the mux->deinit, so
we should add a rtp_deinit() to free all internal allocations.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-03 23:31:17 +00:00
zhanghongyuan 52f9e8c205 fftools/opt_common: Make -sources/-sinks options work without arguments
The -sources and -sinks options were defined with OPT_FUNC_ARG flag,
which requires an argument. This caused "Missing argument for option
'sources'" error when running ffprobe -sources without arguments.
Removing OPT_FUNC_ARG flag allows these options to work without
arguments, listing all available devices, while still supporting
optional device name argument for filtering specific devices.
2026-02-03 23:22:03 +00:00
WyattBlue 065c2582c0 avfilter/af_whisper: Add newline for txt format 2026-02-03 21:45:43 +00:00
Ruikai Peng 55d5b2b507 avfilter/drawvg: limit VGS parser recursion depth 2026-02-03 21:07:29 +00:00
Oliver Chang a795ca89fa avcodec/qdm2: fix heap-use-after-free in qdm2_decode_frame
The `sub_packet` index in `QDM2Context` was not reset to 0 when
`qdm2_decode_frame` started processing a new packet. If an error
occurred during the decoding of a previous packet, `sub_packet` would
retain a non-zero value.

In subsequent calls to `qdm2_decode_frame` with a new packet, this
non-zero `sub_packet` value caused `qdm2_decode` to skip
`qdm2_decode_super_block`. This function is responsible for initializing
packet lists with pointers to the current packet's data. Skipping it led
to the use of stale pointers from the previous (freed) packet, resulting
in a heap-use-after-free vulnerability.

This patch explicitly resets `s->sub_packet = 0` at the beginning of
`qdm2_decode_frame`, ensuring correct initialization for each new
packet.

Fixes: OSS-Fuzz issue 476179569
(https://issues.oss-fuzz.com/issues/476179569).
2026-02-03 18:17:32 +00:00
Jun Zhao 17d89757cd checkasm/hevc_pel: rename loop variable 'size' to 'idx' to avoid confusion
The variable 'size' is used as a loop index for the 'sizes' array.
This naming similarity is error-prone and recently led to a typo where
'size[sizes]' was written instead of 'sizes[size]'.

Rename the loop index variable from 'size' to 'idx' across all 10 test
functions to make the code more readable and prevent similar typos.

Additionally, replace the hardcoded loop upper bound '10' with
'FF_ARRAY_ELEMS(sizes)' for better maintainability.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-03 14:39:31 +00:00
Jun Zhao 2801d5eafe checkasm/hevc_pel: fix typo size[sizes] -> sizes[size]
Commit 4d4b301e4a introduced a typo where `size[sizes]` was used
instead of `sizes[size]` in 10 places within checkasm_check_pixel_padded
calls.

Since `sizes` is an array and `size` is the loop index, `size[sizes]`
interprets the array pointer as an index, resulting in undefined behavior
and causing AddressSanitizer to detect buffer overflows during testing.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-03 14:39:31 +00:00
Michael Niedermayer 2df0ef601a avcodec/jpeg2000dec: allow bpno of -1
Fixes: tickets/4663/levels30.jp2

The file decodes without error messages and no integer overflows
The file before the broader M_b check did decode with error messages and integer overflows but also no visual artifacts

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00
Michael Niedermayer e1472a4e0c avcodec/jpeg2000dec: allow M_b == 31
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00