1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-13 21:28:01 +02:00
Commit Graph

114718 Commits

Author SHA1 Message Date
Michael Niedermayer
0e44de3b9b
avformat/mxfdec: Check body_offset
Fixes: signed integer overflow: 538976288 - -9223372036315799520 cannot be represented in type 'long'
Fixes: 68060/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5523457266745344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 20a6bfda0f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:32 +02:00
Michael Niedermayer
dba4b859d8
avformat/kvag: Check sample_rate
Fixes: Division by 0
Fixes: -copyts -start_at_zero -itsoffset 00:00:01 -itsscale 1 -ss 00:00:02  -i zgclab/ffmpeg_crash/poc1 output.mp4

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c26a762ea1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:32 +02:00
Michael Niedermayer
e806d36b38
avcodec/atrac9dec: Check init_get_bits8() for failure
Fixes: CID1439569 Unchecked return value
Fixes: CID1439578 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 615c994739)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:31 +02:00
Michael Niedermayer
c42248f466
avcodec/ac3_parser: Check init_get_bits8() for failure
Fixes: CID1420393 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 63415168db)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:31 +02:00
Michael Niedermayer
a0577e9877
avcodec/pngdec: Check last AVFrame before deref
Fixes: NULL pointer dereference
Fixes: 68184/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APNG_fuzzer-4926478069334016

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 091fdce87e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:31 +02:00
Michael Niedermayer
62d3e4fd29
avcodec/hevcdec: Check ref frame
Fixes: NULL pointer dereferences
Fixes: 68197/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-6382538823106560

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 5eb05f4450)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:30 +02:00
Michael Niedermayer
7fa0143d7e
doc/examples/qsv_transcode: Initialize pointer before free
Fixees: CID1517023 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit cae0f2bc55)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:30 +02:00
Michael Niedermayer
70191fc0a6
doc/examples/qsv_transcode: Simplify str_to_dict() loop
Fixes: CID1517022 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 191950d1bf)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:30 +02:00
Michael Niedermayer
6b42ba2094
doc/examples/vaapi_transcode: Simplify loop
Fixes: CID1428858(1/2) Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "mypopy@gmail.com" <mypopy@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c9c11a0866)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:29 +02:00
Michael Niedermayer
53868f5193
doc/examples/qsv_transcode: Simplify loop
Fixes: CID1428858(2/2) Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 82cce20934)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:29 +02:00
Michael Niedermayer
ad26b2d05a
avcodec/cbs_h2645: Check NAL space
Found-by-reviewing: CID1419833 Untrusted loop bound

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b91e3c4c90)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:29 +02:00
Michael Niedermayer
1dbfdd2d30
avfilter/vf_thumbnail_cuda: Set ret before checking it
Fixes: CID1418336 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 02301017d2)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:28 +02:00
Michael Niedermayer
4197c3203b
avfilter/signature_lookup: Dont copy uninitialized stuff around
Fixes: CID1403238 Uninitialized pointer read
Fixes: CID1403239 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e7174e66ac)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:28 +02:00
Michael Niedermayer
ba031f8771
avfilter/signature_lookup: Fix 2 differences to the refernce SW
Fixes: CID1403227 Division or modulo by float zero

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 25cb66369e)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-22 22:04:28 +02:00
Andreas Rheinhardt
935279b855 avcodec/x86/vp3dsp_init: Set correct function pointer, fix crash
Regression since fd172185580c1ccdcfb90bbfdb59fa806fad3117;
triggered by vp4/KTkvw8dg1J8.avi in the FATE suite, but not
when running fate as this code is not used when the bitexact
flag is set.

Bisecting done by ami_stuff, patch from user Mika Fischer
in ticket #10027 (which this commit fixes).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit c3ca90a92e)
2024-05-22 16:50:05 +02:00
Marton Balint
52132f4d6e avformat/mp3dec: change bogus error message if read_header encounters EOF
Because of ffio_ensure_seekback() a seek error normally should only happen if
the end of file is reached during checking for the junk run-in. Also use proper
error code.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 49e018d6fe)
2024-05-21 08:43:07 +02:00
Marton Balint
89ea8af0b3 avformat/mp3dec: simplify inner frame size check in mp3_read_header
We are protecting the checked buffer with ffio_ensure_seekback(), so if the
inner check fails with a seek error, that likely means the end of file was
reached when checking for the next frame. This could also be the result of a
wrongly guessed (larger than normal) frame size, so let's continue the loop
instead of breaking out early. It will end sooner or later anyway.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit b75e604fe5)
2024-05-21 08:42:59 +02:00
Marton Balint
07ee3648b7 avformat/mp3dec: only call ffio_ensure_seekback once
Otherwise the subsequent ffio_ensure_seekback calls destroy the buffer of the
earlier. The worst case ~66kB seekback is so small it is easier to request it
entirely.

Fixes ticket #10837, a regression since
0d17f5228f.

Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit b005317219)
2024-05-21 08:41:49 +02:00
James Almer
060d2ce8ae avcodec/cbs_h266: read vps_ptl_max_tid before using it
Reviewed-by: Nuo Mi <nuomi2021@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit b113050d96)
2024-05-20 14:31:03 -03:00
Nuo Mi
00ccb7be29 avcodec/cbs_h266: fix sh_collocated_from_l0_flag and sh_collocated_ref_idx infer
we have to infer sh_collocated_from_l0_flag and sh_collocated_ref_idx from picture head if pps_rpl_info_in_ph_flag is true

(cherry picked from commit 191fbd7ddc)
2024-05-20 14:31:03 -03:00
James Almer
a8b8b1042f avformat/vvc: fix parsing some early VPS bitstream values
vps_default_ptl_dpb_hrd_max_tid_flag needs to always be set, and
vps_direct_ref_layer_flag needs to be read even when
vps_max_tid_ref_present_flag is false.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit a48203d51a)
2024-05-20 14:27:42 -03:00
James Almer
5f23eecfba avformat/vvc: fix writing general_constraint_info bytes
The existing implementation was completely broken.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 415dfa89e2)
2024-05-20 14:27:42 -03:00
Brad Smith
8b0fe91754 avutil/ppc/cpu: Also use the machdep.altivec sysctl on NetBSD
Use the machdep.altivec sysctl on NetBSD for AltiVec detection
as is done with OpenBSD.

(cherry picked from commit 115c96b9bd)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-18 19:34:14 -04:00
Brad Smith
6ab65792ab lavd/v4l2: Use proper field type for second parameter of ioctl() with BSD's
The proper type was used until 73251678c8.

This covers all of the OS's that currently have V4L2 support, permutations
of Linux glibc/musl, Android bionic, FreeBSD, NetBSD, OpenBSD, Solaris.

Copied from FreeBSD ports patch.

Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
(cherry picked from commit 9e674b3160)
Signed-off-by: Brad Smith <brad@comstyle.com>
2024-05-18 19:33:46 -04:00
Mark Thompson
e7d2238ad7 vulkan_av1: Fix force_integer_mv value
(cherry picked from commit 7b482815a0)
2024-05-06 21:33:30 +01:00
Mark Thompson
a4bc1dd928 vaapi_av1: Fix force_integer_mv value
(cherry picked from commit b73e6af337)
2024-05-06 21:33:25 +01:00
Mark Thompson
c3665ee60f av1dec: Add force_integer_mv derived field for decoder use
This is not the same as the syntax element value in the frame header
because the specification parsing tables override the value on intra
frames.

(cherry picked from commit 6f56e0e7e5)
2024-05-06 21:33:03 +01:00
James Almer
a51c06b42c avutil/iamf: fix offsets for mix_gain options
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit d6e877bbcd)
2024-05-04 21:33:32 -03:00
Michael Niedermayer
da8b2f9704 avformat/iamfdec: check nb_streams in header read
Fixes: Assertion pkt->stream_index < (unsigned)s->nb_streams && "Invalid stream index.\n" failed at libavformat/demux.c:572
Fixes: 67890/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-5166340789829632.fuzz

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>
(cherry picked from commit 9f54c13bc4)
2024-05-01 15:46:44 -03:00
James Almer
1e6382a6b7 avformat/mov: free the infe allocated item data on failure
Fixes: memleak
Fixes: 68212/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4963488540721152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit e09164940e)
2024-05-01 15:45:53 -03:00
James Almer
5683aa6318 avformat/iamf_writer: reject duplicated stream ids in a stream group
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 6b6a0fc53d)
2024-05-01 15:45:53 -03:00
James Almer
fb8f0ea7b3 avformat/mov: don't read key_size bytes twice in the keys atom
We only support mdta as type, yet we were not skipping other types,
but rather reading key_size worth of bytes twice per entry.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 5a06d3810e)
2024-04-29 09:46:18 -03:00
James Almer
0085da21b4 avformat/mov: take into account the first eight bytes in the keys atom
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 3d12ba77d9)
2024-04-29 09:46:18 -03:00
James Almer
64a048d4cc avformat/mov: fix the check for the heif item parsing loop
Fixes: Null pointer dereference
Fixes: 67861/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5352628142800896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 31327c2d07)
2024-04-29 09:33:08 -03:00
James Almer
96d941b30e avutil/iamf: fix mix_gain_class name
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit b9af58184f)
2024-04-24 19:07:11 -03:00
Mark Thompson
9963b9e3c9 av1dec: Fix RefFrameSignBias calculation
(cherry picked from commit ba6b08c75b)
2024-04-24 17:36:01 +02:00
James Almer
506fbe681c avcodec/codec_par: always clear extradata_size in avcodec_parameters_to_context()
Missed in d383ae43c2.

Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit c4e3d6cdb0)
2024-04-24 00:17:16 -03:00
Zhao Zhili
13e93ffbfd avcodec/mediacodecenc: Fix return empty packet when bsf is used
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
(cherry picked from commit a5a3788f56)
2024-04-23 16:10:28 +08:00
Andreas Rheinhardt
2d3ee7c069 avcodec/hevcdec: Fix precedence, bogus film grain warning
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit bba996d6cd)
2024-04-22 23:43:03 +03:00
Niklas Haas
30002d58fa avcodec/hevcdec: fix segfault on invalid film grain metadata
Invalid input files may contain film grain metadata which survives
ff_h274_film_grain_params_supported() but does not pass
av_film_grain_params_select(), leading to a SIGSEGV on hevc_frame_end().

Fix this by duplicating the av_film_grain_params_select() check at frame
init time.

An alternative solution here would be to defer the incompatibility check
to hevc_frame_end(), but this has the downside of allocating a film
grain buffer even when we already know we can't apply film grain.

Fixes: https://trac.ffmpeg.org/ticket/10951
(cherry picked from commit 459648761f)
2024-04-22 23:43:03 +03:00
Frank Plowman
cbd98447bc lavc/vvc: Skip enhancement layer NAL units
The native VVC decoder does not yet support quality/spatial/multiview
scalability.  Bitstreams requiring this feature could cause crashes.
Patch fixes this by skipping NAL units which are not in the base layer,
warning the user while doing so.

Signed-off-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit bb9e4ff355)
2024-04-18 22:29:31 -03:00
James Almer
ed55219edd avformat/mov: ignore old infe box versions
Some files with no image items have them, and were working prior to the recent
HEIF parsing overhaul.
Ignore such boxes instead, to recover the old behavior.

Fixes a regression since d9fed9df2a.

Tested-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 5b9db32ccc)
2024-04-18 13:03:11 -03:00
Lynne
8dfafe5366 vulkan_av1: add workaround for NVIDIA drivers tested on broken CTS
The first release of the CTS for AV1 decoding had incorrect
offsets for the OrderHints values.
The CTS will be fixed, and eventually, the drivers will be
updated to the proper spec-conforming behaviour, but we still
need to add a workaround as this will take months.

Only NVIDIA use these values at all, so limit the workaround
to only NVIDIA. Also, other vendors don't tend to provide accurate
CTS information.

(cherry picked from commit db09f1a5d8)
2024-04-16 18:14:32 +02:00
Mark Thompson
48721a415a lavc/vulkan_av1: Use av1dec reference order hint information
(cherry picked from commit 3cca8dfbd8)
2024-04-16 18:14:32 +02:00
Mark Thompson
0d851a82dd lavc/av1: Record reference ordering information for each frame
This is needed by Vulkan.  Constructing this can't be delegated to CBS
because packets might contain multiple frames (when non-shown frames are
present) but we need separate snapshots immediately before each frame
for the decoder.

(cherry picked from commit 22ced1edc6)
2024-04-16 18:14:32 +02:00
James Almer
d38bf5e08e doc/encoders: add missing libxvid option
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 6f13f5dd59)
2024-04-05 17:21:54 -03:00
James Almer
6c701b5f6c doc/encoders: remove non-existent flag
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 16ba7bdd76)
2024-04-05 17:14:02 -03:00
Andreas Rheinhardt
e2a1a4f581 fate/ffmpeg: Avoid dependency on samples
Creating vsynth_lena.yuv needs the FATE suite,
yet several tests in ffmpeg.mak without a dependency
on samples used it as input file. Fix this by using
vsynth1.yuv (which does not have such a dependency)
instead.
Also use vsynth1.yuv in fate-shortest to avoid
the samples dependency in this test, too.

Fixes ticket #10947.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 7b7b7819bd)
2024-04-05 17:51:27 +02:00
Andreas Rheinhardt
265de29acb avcodec/wavpack: Remove always-false check
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit d307aca184)
2024-04-05 17:42:01 +02:00
Andreas Rheinhardt
607fca80b7 avcodec/wavpack: Fix leak and segfault on reallocation error
av_realloc_f() frees the buffer it is given on allocation
failure. But in this case, the buffer is an array of
ownership pointers, causing leaks on error. Furthermore,
the count of pointers is unchanged on error and the codec's
close function uses it to free said ownership pointers,
causing a NPD.
This is a regression since 46412a8935.

Fix this by switching to av_realloc_array().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
(cherry picked from commit 2f59648aed)
2024-04-05 01:49:15 +02:00