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

119364 Commits

Author SHA1 Message Date
8bb682d454 avcodec/x86/constants: add pd_64
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-25 23:20:58 -03:00
6dd83fab44 avformat: Use ffio_read_size() where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:22:20 +02:00
122f86d859 avcodec/magicyuv: Simplify check for RGB
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:38 +02:00
7c7e161437 avcodec/magicyuv: Set properties via AVPixFmtDescriptor
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:38 +02:00
c33f16db1b avcodec/webp: Avoid loop
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:38 +02:00
e0a05456cd avcodec/webp: Combine allocations
Or avoid them altogether for the small stage-one VLC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
1fc0ee484f avcodec/webp: Check before allocations
Avoids freeing lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
e0df21b8c3 avcodec/webp: Switch to ff_vlc_init_from_lengths()
The earlier code would traverse over the code lengths
mutliple times (namely max_length + 1 times - once to get
the maximum length and once for each max_length to assign
codes) before calling ff_vlc_init_sparse() (which may traverse
them twice and sort them). The new code only traverses them once
(+ the one time in ff_vlc_init_from_lengths()).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
d60445258c avcodec/webp: Check more directly for invalid codes
Don't rely on invalid codes leading to get_vlc2() returning
-1, which then gets converted to an uint8_t, i.e. to 255
and runs afoul of a length check later. After all, get_vlc2()
could be changed to return something else which may
be valid when cast to uint8_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
6676038b23 avcodec/cbs: Use put_bits63()
It is better when BUF_BITS == 64 (i.e. on x64), because
the underlying put_bits can then handle 0..63 bits naturally.
It does not worsen the code when BUF_BITS != 64, because
the compiler can optimize this to the same code as now
(due to the assert).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
a2acb46a6e avcodec/vp6: Forward error codes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
be7495c32c avcodec/vp6: Use fewer number of bits in run VLCs
Given that these trees have only nine elements and are complete,
their depth is <= eight.

Also remove the now unused FF_HUFFMAN_BITS constant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
e946ba64bf avcodec/vp6: Don't reload unnecessarily often in get_vlc2()
The VLC trees used here have very few different codes
and are therefore guaranteed to not be very deep: The AC/DC
VLCs have 12 elements and therefore a depth <= 11 whereas
the run VLCs have only nine elements and therefore a depth <= 8.
This allows to reduce the worst-case number of reloads for
reading a VLC code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
57b7783c22 avcodec/vp6: Don't initialize unused VLC tables
There are only 2*3*4 VLC trees for decoding Huffman encoded
AC coefficients; see section 13.3.2 of the spec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
3e21df2353 avcodec/huffman: Switch to ff_vlc_init_from_lengths()
Avoids having to create the codes ourselves.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 23:01:37 +02:00
e73c59c6c3 tools/target_dec_fuzzer: Assert on AVERROR_BUG
This will bring these bugs to our attention.

Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 12:35:48 +02:00
40544b4854 avcodec/ftr: Replace AVERROR_BUG that can be triggered
Return AVERROR_DECODER_NOT_FOUND.
(This can be triggered because this decoder tries to be
generic and work with multiple underlying AAC decoders,
so that there is no configure dependency for any decoder.)

Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 12:35:45 +02:00
0279eb9c93 avcodec/imm5: Reference H.264/HEVC decoders directly
This is simpler and allows to fuzz them -- up until now,
the linker did not see the dependency and fuzzing them
returned AVERROR_BUG during init.
It took just a few seconds here to run into an assert
due to a return value of AVERROR(EAGAIN) in the decode
callback...

Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 12:35:40 +02:00
0d9b0015ba tools/target_dec_fuzzer: Remove mjpeg hack
ff_mjpeg_decoder is now referenced directly by the relevant
decoders, so that the linker sees the dependency and
just does the desired thing. So remove the hack.

(Btw: The preprocessor does not do string comparisons, instead
undefined tokens in #if checks evaluate to 0, making the check
true regardless of the actual codec fuzzed (and leading to
linker errors if the mjpeg decoder is disabled).)

Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 12:35:28 +02:00
289cb3beff avcodec/cri,tdsc,tiff: Use ff_mjpeg_decoder directly
This is simpler than calling avcodec_find_decoder().
Notice that av_codec_init_static() has already been called
by the time we reach these decoders' init functions,
so it is not necessary to call avcodec_find_decoder()
for it (which doesn't do anything for the mjpeg decoder
anyway).

Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-25 12:31:54 +02:00
25b0a8e295 avcodec/h264_slice: insert LCEVC side data before get_buffer() call
Otherwise it will not be taken into account or applied at all.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-23 09:41:03 -03:00
37bd915042 vulkan: use _KHR suffix for push descriptor properties struct ID 2025-04-23 01:46:37 +02:00
09a83e095d rtpdec_mpeg4: Add fmtp parsing of bitrate value
According to RFC 6416 the audio stream sender can pass the data rate
for the audio bitstream as "bitrate=" media format parameter.

Signed-off-by: Marvin Scholz <epirat07@gmail.com>
2025-04-22 21:09:10 +02:00
cacc68f3b5 ffbuild: fix include path for uninstalled .pc files 2025-04-22 21:04:36 +02:00
0ea83e65aa avfilter/drawutils: narrow variable scopes 2025-04-22 20:59:16 +02:00
d0bcf62597 tools/aviocat: use av_err2str
There is no need to explicitly specify the buffer, as it
is only ever passed to fprintf, so av_err2str can be used.
2025-04-22 20:45:57 +02:00
da38b2fcd2 tools/sidxindex: use av_err2str
There is no need to explicitly specify the buffer, as it
is only ever passed to fprintf, so av_err2str can be used.
2025-04-22 20:45:57 +02:00
a903d6dade tools/ismindex: use av_err2str
There is no need to explicitly specify the buffer, as it
is only ever passed to fprintf, so av_err2str can be used.
2025-04-22 20:45:57 +02:00
b781f1836e tests: lavfi/drawutils: use av_err2str
There is no need to explicitly specify the buffer, as it
is only ever passed to printf, so av_err2str can be used.
2025-04-22 20:45:57 +02:00
d7d103c34c lavfi/vf_xpsnr: use av_err2str
There is no need to explicitly specify the buffer, as it
is only ever passed to av_log, so av_err2str can be used.
2025-04-22 20:45:57 +02:00
cd96d2ed6a avformat/crypto: use av_err2str
There is no need to explicitly specify the buffer, as it
is only ever passed to av_log, so av_err2str can be used.
2025-04-22 20:45:57 +02:00
8129474b93 avformat/dashdec: use av_err2str
There is no need to explicitly specify the buffer, as it
is only ever passed to av_log, so av_err2str can be used.
2025-04-22 20:45:57 +02:00
3bb2b8aff4 hwcontext_vulkan: enable subgroupSizeControl
We already use this feature for setting the subgroup size,
but this feature was not enabled.

Fixes a validation warning.
2025-04-22 13:43:20 +02:00
96ddce1b3c vulkan: move OPT_CHAIN out of hwcontext_vulkan
This allows for it to be shared.
Technically, implementations should not give drivers structs
that the drivers are not familiar with.
2025-04-22 13:43:19 +02:00
cee34e0a55 vulkan: check that the max number of push descriptors is not exceeded
Just correctness. We don't exceed this on any known hardware, but
its better to check.
If we do, we simply fall back to regular descriptors.
2025-04-22 13:43:19 +02:00
5098b1a345 vulkan: move feature<->usage mapping code outside of hwcontext_vulkan.c
Allows for it to be reused. In particular, for a future patch to make
vulkan hwaccels output DMABUF-backed VkImages.
2025-04-22 13:43:17 +02:00
b6c2498a59 avformat/takdec.c: return proper error codes for avio_read() failures
Suggested-by: Nicolas George <george@nsup.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-21 14:08:23 -03:00
1d244c641b libavformat/takdec.c: Fix msan error
Make sure we are reading 16 bytes for the MD5

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-21 14:08:23 -03:00
df824211c2 avcodec/vc2enc: Improve error codes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-21 17:02:44 +02:00
494061a49a avcodec/vp8: Maintain consistency of frame pointers
Right now it is possible for the pointer for the current frame to
be set in the context even when it could not be properly set up;
this does not influence the ordinary ref frames, but only
VP8Context.prev_frame. And since this code has been ported to the
ProgressFrame API in d48d7bc434,
this leads to segfaults, because the ProgressFrame API is less
forgiving than the ThreadFrame API (waiting on an uninitialized
ProgressFrame segfaults, waiting on an uninitialized ThreadFrame
is a no-op (the code behaves as if frame-threading is not in use)).

Fix this by maintaining the consistency of the frame pointers
in the context (by setting them later).

Fixes: NULL pointer dereference
Fixes: 68192/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP8_fuzzer-6180311026171904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-21 16:43:39 +02:00
9e1162bdf1 avutil/hwcontext: Add item_name function for AVHWDeviceContext
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-04-21 00:19:20 +02:00
bf1579c904 avutil/log,hwcontext: Add AV_CLASS_CATEGORY_HWDEVICE
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-04-21 00:19:11 +02:00
3cf21217b5 avcodec/dvbsubenc: Check nb_colors before using it
Avoids a potential overflow when multiplying nb_colors by 6.
Also make the nb_colors check a bit more strict.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:08:01 +02:00
3acc3b0b50 avcodec/dvbsubenc: Sanity check num_rects
It is written as region_id which is a single byte.
Also fixes a potential (defined) overflow in the num_rects * 6
multiplication later; this has been found by 김승호 <kimsho98@naver.com>.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:07:48 +02:00
bad3f308d3 avcodec/magicyuvenc: Hoist check out of loop
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:04:36 +02:00
d42ba1384a avcodec/magicyuvenc: Avoid excessive logmessages
AVERROR(ENOMEM) is enough.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:04:36 +02:00
cf288000e5 avcodec/magicyuvenc: Switch to unchecked bytestream2 API
We have already calculated the size of the packet
and therefore don't need to rely on these implicit checks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:04:36 +02:00
1ab50cced5 avcodec/magicyuvenc: Calculate proper packet size in advance
This can be easily done because we have a count of the number of
values and the length of the associated codes. This allows
to switch to ff_get_encode_buffer() and thereby avoids an implicit
intermediate buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:04:36 +02:00
9c69e94354 avcodec/magicyuvenc: Avoid PutBitContext for byte-aligned writes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:04:36 +02:00
3a90bbe4b7 avcodec/magicyuvenc: Simplify padding slice
Do it before writing the actual slice to be able to use
a single AV_WN32().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-20 22:04:36 +02:00