1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00
Commit Graph

120496 Commits

Author SHA1 Message Date
a45755e302 avcodec/dxvenc: Clear width to linesize not linesize to linesize
Fixes: use of uninitialized memory
Fixes: 422217206/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_fuzzer-4786889444098048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:38 +02:00
909229b880 avcodec/shorten: Clear the additionally allocated space on realloc
Fixes: use of uninitialized memory
Fixes: 421954767/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-515682786246656

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:38 +02:00
1b7a327b3a avformat/vqf: Ensure that comm_chunk is fully read
Fixes: use of uninitialized memory
Fixes: 412125811/clusterfuzz-testcase-minimized-ffmpeg_dem_VQF_fuzzer-6253774274887680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:37 +02:00
c6cb3ab7ff avformat/mxfdec: Ensure klv->key is initialized
Fixes: read of uninitialized memory
Fixes: 391916474/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4935250956845056

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:37 +02:00
8b16e1ddd9 avformat/mov: make sure file_checksum is fully initialized
Fixes: use of uninitialized memory
Fixes: 394990189/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6431722199908352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:37 +02:00
7a21c37f75 avcodec/hevc/hevcdec: Clean sao_pixel_buffer_v on allocation
Fixes: use of uninitialized memory
Fixes: 378102648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5896308499480576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:36 +02:00
fa197924a6 avformat/asfdec_f: Check amount of value read
Fixes: use of uninitialized memory
Fixes: 403675492/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_fuzzer-4754281823797248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:36 +02:00
23c60ce742 tools/target_dec_fuzzer: Set ALS max order to 15 (ALS simple profile)
Fixes: Timeout
Fixes: 429645375/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5377900448907264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:27:52 +02:00
0887d2e291 avcodec/alsdec: Allow the user to set a maximum prediction order
The only offical profile i could find (ALS simple profile) has a max of 15 while the bitstream allows 1023
which is very slow.

We do have a fate sample with 1023

Fixes: Timeout
Fixes: 429645375/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5377900448907264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:27:52 +02:00
0a108a37e1 avformat/hlsenc: limit segments count to search duplicated segments filenames
This linear search has a complexity of O(n). When ffmpeg attempts to parse a playlist containing approximately 100,000 segments, it effectively causes a hang for several minutes.

This patch limits the allowed size for duplicate searches to a reasonable value. Now it takes between 0.5 and a few seconds (tested on different devices) instead of several minutes.

Signed-off-by: Artem Smorodin <artem.smorodin@dacast.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:27:51 +02:00
4b6f6af384 avformat/movenc: fix HEVC fmp4 HLS init segment for Apple playback
HEVC fmp4 HLS video produced by ffmpeg is currently unplayable on Apple
software (Safari, QuickTime, AVFoundation).

This is caused by an empty sdtp atom being erroneously written to the
fmp4 init segment. The `has_disposable` flag can be set for a track
with B-frames, but the init segment contains no actual frames
(track->entry == 0). Writing an sdtp atom in this case is incorrect
and causes Apple's parsers to reject the file.

This patch fixes the issue by ensuring the sdtp atom is only written
if track->entry is non-zero.

A similar patch was proposed in November 2023 by Jay Zhang,
but it was never merged.

Link: https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2023-November/317173.html
Co-authored-by: Jay Zhang <wangyoucao577@gmail.com>
Signed-off-by: David McElroy <david@mcelroy.online>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:27:51 +02:00
dc8e753f32 avfilter/vf_libplacebo: composite multiple inputs in linear light
This gives vastly improved blending results than when blending directly in
the desired output colorspace. Overridable by the existing "disable_linear"
option.

This is functionally similar to combining multiple "libplacebo" filters,
but does not rely on the existence of a Vulkan filter link, so it can be used
without performance penalty in all circumstances. It's also enabled by
default, without requiring special action from the user.
2025-07-28 10:59:48 +02:00
603334a043 avfilter/vf_premultiply: use correct premultiplication formula
The previous formula was introduced without justification in 6e713841e8,
and the only thing Paul had to say about it over IRC was that it was copied
from an unspecified source on the internet.

I decided to do some testing and came to the conclusion that this term not
only produces "illegal" files, but also lowers PSNR score, over the naive
implementation without this extra term.

Here are the results of a round-trip test, using allrgb/allyuv (respectively)
as the input, and fade=alpha=yes:n=256 to cycle through every possible alpha
value, comparing the round-trip output against the input:

Before patch:
  PSNR r:26.677431 g:26.677431 b:26.677431 a:inf average:27.926818 min:6.012093 max:55.400791
  PSNR y:26.677431 u:21.101981 v:21.101981 a:inf average:23.548981 min:9.013835 max:53.182303 (full)
  PSNR y:27.348055 u:21.101981 v:21.101981 a:inf average:23.625238 min:9.554991 max:45.652221 (limited)

After patch:
  PSNR r:27.321996 g:27.321996 b:27.321996 a:inf average:28.571384 min:6.012093 max:52.424553
  PSNR y:27.321996 u:23.187879 v:23.187879 a:inf average:25.431773 min:9.013835 max:50.199232 (full)
  PSNR y:27.868544 u:23.187879 v:23.187879 a:inf average:25.515660 min:9.554991 max:45.078298 (limited)

It's worth pointing out that previous version sometimes artificially inflates
PSNR by producing values that are too high (i.e. RGB > A), such as for the
input pair (R = 255, A = 2) which should give R = 2, but actually gives R = 3
under the old logic.

As a second evaluation without this shortcoming, here is a comparison against
the reference value computed with a floating point format:

Before patch:
  PSNR r:53.600599 g:53.957833 b:53.540948 a:inf average:54.945316 min:50.508901 max:inf (premul only)
  PSNR r:30.734183 g:30.734183 b:30.734183 a:inf average:31.983570 min:12.058264 max:inf (round-trip)

After patch:
  PSNR r:61.751104 g:65.239091 b:61.339191 a:inf average:63.710714 min:55.441130 max:inf (premul only)
  PSNR r:32.611851 g:32.611851 b:32.611851 a:inf average:33.861238 min:12.058264 max:inf (round-trip)
2025-07-28 10:56:10 +02:00
e74dbb02eb avcodec/dovi_rpudec: skip unknown ext blocks instead of erroring out
Should allow for forward compatibility with newer versions.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-27 12:16:00 +00:00
ef167512ab avcodec/dovi_rpudec: parse RPU forward, don't try to find end
Instead of scanning backwards for the end of RPU payload, parse it and
report if we didn't land at the terminator byte.

Current expectation was that we can have additional zero bytes after RPU
payload, which were skipped to find playload end. That's not always the
case. So loosen this requirement.

This fixes files where there is additional non-zeroed padding after the
end of the RPU in NALU.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-27 14:09:46 +02:00
bf640b53db avcodec/hevc/hevcdec: handle rpu_buf allocation failure correctly
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-27 14:09:46 +02:00
29368ccb48 forgejo/workflows: use explicit token with issue write permission 2025-07-26 19:36:56 +02:00
631bb6c6e8 avformat/mxfenc: Ensure frame offset in valid range
Fix assert failure.
Fix #11666.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-07-26 21:04:57 +08:00
dc0ac81bbe avcodec/cuviddec: fix wrong 10bit 420 format in cuvid_handle_video_sequence 2025-07-26 14:42:33 +02:00
a56da996ce avcodec/cuviddec: also reflect new pix_fmts in cuvid_handle_video_sequence 2025-07-26 14:42:05 +02:00
2513f3d604 forgejo/workflows: add issue/PR auto labeler 2025-07-26 14:36:04 +02:00
e29016a9de avformat/subfile: clip seek offset
Fixes: signed integer overflow: 9223372036854737920 + 1649410 cannot be
represented in type 'int64_t'

Fixes OSS-Fuzz: 410100610

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 22:00:02 +02:00
d12863a693 avformat/rtmpproto: guard usage of undefined functions with preprocessor
The asumption is that DCE will remove references to those functions.
However some compilers with certain instrumentation enabled doesn't DCE
those at all, resulting in linking failure. Tested with cl.exe -RTCu -RTCs.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:18:17 +02:00
40b56c6536 avcodec/x86/vc1: guard usage of undefined functions with preprocessor
The asumption is that DCE will remove references to those functions.
However some compilers with certain instrumentation enabled doesn't DCE
those at all, resulting in linking failure. Tested with cl.exe -RTCu -RTCs.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
9658d4425e avcodec/x86/fdct: guard usage of undefined functions with preprocessor
The asumption is that DCE will remove references to those functions.
However some compilers with certain instrumentation enabled doesn't DCE
those at all, resulting in linking failure. Tested with cl.exe -RTCu -RTCs.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
6bc23ab352 avcodec/d3d12va_encode_hevc: remove unused variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
62e2af358d avcodec/d3d12va_encode: don't return uninitialized value on error
When CreateEvent fails, err was not initialized.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
7d9b21601c avcodec/d3d12va_encode: don't write garbage when there is no header
When codec->write_sequence_header is not defined, bit_len was undefined,
and while data bufer was zeroed we could just overread it. Do nothing
when we don't have anything to write.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
a1588c875a avcodec/d3d12va_encode: use correct none flag
NFC, it's still 0, but correct enum type so compilers won't complain.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
c1ccd4bb22 avcodec/d3d12va_decode: remove unused variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
a9b9636046 avformat/vivo: fix sscanf specifer for double
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
c6ea6ac39b avformat/os_support: check invalid socket value correctly on Windows
SOCKET defined in winsock2.h is unsigned and invalid value is defined as
INVALID_SOCKET. Check this explicity to avoid compiler warnings.

See: https://learn.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
d6b72d1d26 avformat/options_table: supress implicit conversion warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:13 +02:00
45810daf4d avfilter/af_channelmap: always set out_channel in the map
Fixes use-of-uninitialized-value.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-25 00:18:07 -03:00
829680f96a avcodec/jpegxl_parser: add sanity check for frame size
If a frame size is absolutely massive, this can spin the parser as it
attempts to decode a permuted TOC. We add a sanity check here for eight
times the size of the image for an internal frame to prevent malicious
bitstreams from slowing the parser down to a crawl.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-23 06:22:16 -04:00
3f2b452a22 avcodec/opus/silk: don't assume stereo when calling silk_decode_frame()
Fixes use-of-uninitialized-value under MSAN.

Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 22:16:25 -03:00
33e326ae02 forgejo/workflows: add initial rudimentary CI
It runs basic fate with no special dependencies enabled on x86_64 and
aarch64.
2025-07-22 20:06:20 +02:00
c64f6812eb configure: suppress Wmicrosoft-enum-forward-reference
Clang-CL complains about fwd references of enums, but we do use it
everywhere, so ignore this.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-22 19:56:34 +02:00
22da57c444 swscale/lut3d: remove unused function
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-22 19:56:34 +02:00
29d274afe7 avformat/udp: avoid warning about always false comparison
socklen_t underlying type can be signed or unsigned depending on
platform. This is fine, just cast it to size_t before comparison.

Fixes: warning: result of comparison of unsigned expression < 0 is
       always false [-Wtautological-unsigned-zero-compare]

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-22 19:56:34 +02:00
ce04877f1f avutil/hmac: avoid calling functions through pointer of invalid type
Add type removed function wrappers to resolve UB of calling function
through pointer to incorrect function type.

Fixes: FATE-{hmac,srtp}
Fixes: call to function av_md5_init through pointer to incorrect
       function type 'void (*)(void *)' and similar for others.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-22 19:56:34 +02:00
6f88b90f6c avutil/avstring: shrink allocation from av_get_token to fit token
av_get_token() allocates an output buffer with the same size as the
input. Generally, this is harmless, but when the input string is large
and consists of many small tokens, calling av_get_token() repeatedly to
extract all tokens will significantly amplify memory allocations.

To fix this, after obtaining the return value, simply realloc the buffer
to the actual size needed for output string.

Fixes OOM when parsing filter graph string.
Fixes OSS-Fuzz: 394983446

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-22 19:56:34 +02:00
86670fec9c avcodec/ffv1dec: don't check chroma_planes for f->colorspace > 0
It's RGB, so check instead if it's packed or planar.

Fixes: libavcodec/ffv1dec.c:461:43: runtime error: applying zero offset to null pointer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 12:37:31 -03:00
da18c2a373 avfilter: use the getters for xGA font data arrays
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
cb9742af76 avcodec: use the getters for xGA font data arrays
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
c6c8063186 avutil/xga_font_data: add getters to access the shared arrays
And stop exposing the arrays on the next major bump.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
e835738b70 avcodec/cbs_apv: add missing READ/WRITE preprocessor checks
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
b0159af6bc avfilter/f_metadata: use the return value of vsnprintf() to write the argument list
Should fix use-of-uninitialized-value under MSAN.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
87cc213748 avformat/hevc: don't print parameter_set_id for any NALU
It's not a value stored in the hvcC structure.
Fixes use of uninitialized variable errors under sanitizer when the input extradata is
already hvcC formatted, given we don't parse parameter sets for those.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
48ef4caac2 avcodec/ffv1dec: don't add offsets to more NULL pointers
Fixes: libavcodec/ffv1dec.c:453:43: runtime error: applying zero offset to null pointer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:17 -03:00