Commit Graph

122256 Commits

Author SHA1 Message Date
James Almer
64be23153e fftools/ffmpeg_sched: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
James Almer
2678482c10 fftools/ffmpeg_enc: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
Michael Niedermayer
9e974b2c45 avformat/hls: fix double space
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 14:14:45 +01:00
Michael Niedermayer
548b28d5b1 avformat/hls: Fix arguments of handle_rendition_args()
Fixes: call to function handle_rendition_args through pointer to incorrect function type 'void (*)(void *, const char *, int, char **, int *)'
Fixes: 464965411/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-4790164406992896

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 12:04:07 +00:00
Michael Niedermayer
d1985442e1 avformat/hls: Check seg size and offset for overflow
Fixes: integer overflow
Fixes: signed integer overflow: 9223372036854775807 + 2039324394 cannot be represented in type 'int64_t' (aka 'long')

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 12:04:07 +00:00
Michael Niedermayer
8ac6325143 avcodec/adpcm: check block_align for PSXC
Fixes: division by 0
Fixes: 457634826/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_PSXC_DEC_fuzzer-4903668521697280

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 02:51:20 +00:00
Jack Lau
13c91c97d1 avcodec/libjxldec: goto SUCCESS when frame is completed
Fix #21260

The early code didn't reset the JxlDecoder. If the
caller re-send the same packet to JxlDecoder after
avcodec_flush_buffers() (free ctx->frame). It will
directly hit SUCCESS event (skip all EVENTs).

In this case, the ctx->frame already flushed by
avcodec_flush_buffers, so the received frame
will be invalid (has no private_ref) that causes
assertion in decode_receive_frame_internal().

MPV meet this issue because it seek the jxl image
(second read the same pkt) when it does crop
through config `C vf toggle crop=in_w:in_w/2.4`.

This patch make sure hit the entire SUCCESS event
(contains reset the JxlDecoder) when frame_complete
is true.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-24 02:43:50 +00:00
Michael Niedermayer
d60c1d72c1 avcodec/jpeg2000dec: Make M_b check broader
Fixes: shift exponent -1 is negative
Fixes: 429330004/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-4733213845291008

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-23 20:11:29 +00:00
Lynne
e5eef271a5 vulkan: set .decode_extension to 0 for compute-based decoders
They require no special video decode extension. The push descriptor
extension was a placeholder for when the check was performed inside
the init function.
2025-12-23 15:42:24 +01:00
Damitha Gunawardena
bb769d9d90 avcodec/gifenc: avoid redundant local color table when global palette is used
Addressing the fact that first frame has a LCT when global pallette is used for pal8.
issue: #20896
2025-12-23 14:34:13 +00:00
Andreas Rheinhardt
26a7fc2ac4 avfilter/vf_waveform: Avoid relocations
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-23 11:02:04 +01:00
Andreas Rheinhardt
6460d3bc81 avfilter/vf_waveform: don't cast const away
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-23 11:01:42 +01:00
Michael Niedermayer
d41b8d95a7 swscale/output: Use 64bit in addition in yuv2gbrp16_full_X_c() for RGB + Y
Fixes: signed integer overflow: -1159988356 + -1082982400 cannot be represented in type 'int'
Fixes: 461519938/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4777382021234688

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-23 09:14:44 +00:00
Zhao Zhili
09d8300779 avutil/imgutils: use AV_CEIL_RSHIFT 2025-12-23 03:39:16 +00:00
Zhao Zhili
260f5a47a5 avformat/rawvideodec: add stride option to skip line padding
Some tools like v4l2-ctl dump data without skip padding. If the
padding size is not an integer multiple of the number of pixel
bytes, we cannot handle it by using a larger width, e.g.,, for
RGB24 image with 32 bytes padding in each line.
2025-12-23 03:20:34 +00:00
Zhao Zhili
49a15e70be avformat/rawvideodec: use AV_OPT_TYPE_PIXEL_FMT instead of parse from string manually 2025-12-23 03:20:34 +00:00
Romain Beauxis
5ae21f06a3 tests/fate/id3v2.mak: Use run wrapper in fate-id3v2-invalid-tags 2025-12-22 22:34:48 +00:00
Niklas Haas
fafd72ef04 swscale/ops_internal: fix ff_sws_pack_op_decode()
This function was assuming that the bits are MSB-aligned, but they are
LSB-aligned in both practice (and in the actual backend).

Also update the documentation of SwsPackOp to make this clearer.

Fixes an incorrect omission of a clamp after decoding e.g. rgb4, since
the max value range was incorrectly determined as 0 as a result of unpacking
the MSB bits instead of the LSB bits:

 bgr4 -> gray:
   [ u8 XXXX -> +XXX] SWS_OP_READ         : 1 elem(s) packed >> 1
   [ u8 .XXX -> +++X] SWS_OP_UNPACK       : {1 2 1 0}
   [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> .++X] SWS_OP_LINEAR       : dot3 [...]
   [f32 .XXX -> .++X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
+  [f32 .XXX -> .++X] SWS_OP_MIN          : x <= {255 _ _ _}
   [f32 .XXX -> +++X] SWS_OP_CONVERT      : f32 -> u8
   [ u8 .XXX -> +++X] SWS_OP_WRITE        : 1 elem(s) planar >> 0
     (X = unused, + = exact, 0 = zero)
2025-12-22 20:14:31 +00:00
Lynne
6656b11a7b hwcontext_vulkan: disable host transfers on MoltenVK
https://github.com/KhronosGroup/MoltenVK/issues/2618
2025-12-22 19:46:27 +01:00
Lynne
d33bf66519 vulkan_functions: add vkCmdUpdateBuffer
It embeds the data to be uploaded directly into the command buffer,
which makes it useful for uploading transient data.
2025-12-22 19:46:27 +01:00
Lynne
8db6947700 vulkan_prores_raw: reduce zigzag table size
No need for full 32-bits.
2025-12-22 19:46:27 +01:00
Lynne
cfcf52a08c vulkan: deduplicate shorthand casting defines to common.comp 2025-12-22 19:46:27 +01:00
Lynne
6eced88188 vulkan: merge ProRes and ProRes RAW iDCTs
This cleans up the code a bit, and reduces binary size.
2025-12-22 19:46:26 +01:00
Lynne
ea14f8a28f vulkan_prores: split up shader creation functions
Its more mess that it has to be.
2025-12-22 19:46:26 +01:00
Rémi Denis-Courmont
eb3b632b48 lavc/h264qpel: fix RISC-V stack usage
The function violated the ABI requirement not to write below SP
(this breaks asynchronous signal handling). On RV32, it also broke
did not align SP to 16 bytes and did not restore it correctly.

No changes to benchmarks as this patch only changes a few immediate
offsets.
2025-12-22 18:55:20 +02:00
Rémi Denis-Courmont
65018b3e83 lavu/float_dsp: fix R-V V scalarpdocut_double with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont
435623cbda lavu/float_dsp: fix R-V V vector_dmul_scalar with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont
56d933b0a7 lavu/float_dsp: fix R-V V vector_dmac_scalar with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont
a583639bf0 lavu/fixed_dsp: fix scalarproduct on riscv32
On riscv32, the result must be narrowed from 63 to 32 bit before being
moved to the scalar side.
2025-12-22 18:55:13 +02:00
Araz Iusubov
4479d28103 avcodec/avfilter_amf: correct handling of AMF errors
Fix several AMF-related issues.

Check the return value of amf_init_frames_context() correctly in amfdec,
as it returns int rather than AMF_RESULT.

Handle possible NULL surfaces returned from QueryInterface() in
vf_amf_common to avoid passing invalid data to amf_amfsurface_to_avframe().

Remove FILTER_SINGLE_PIXFMT from vf_sr_amf since it must not be used
together with a query formats function.
2025-12-22 14:58:59 +00:00
Romain Beauxis
b43645b2ef libavformat/id3v2.c: return valid string in decode_str for empty strings
with no bom. Fixes: #YWH-PGM40646-12
2025-12-22 13:44:42 +00:00
Kacper Michajłow
c50e5c7778 avcodec/libaomenc: remove enum type from codecctl_* functions
aom_codec_control() takes control id as int. It could be AV1E_ or common
AV1_ enum in encoder, and AV1D_ for decoder.

While upstream provides AOM_CODEC_CONTROL_TYPECHECKED() macro to check
the provided enum value, we wrap those calls in codecctl_ functions,
which makes it not feasible to use.

To avoid complicating this needlessly, just use int.

Fixes: warning: implicit conversion from enumeration type 'enum aom_com_control_id' to different enumeration type 'enum aome_enc_control_id'
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-22 07:05:58 +01:00
Kacper Michajłow
96afe665ef avcodec/libaomenc: remove UENUM1BYTE check
AOM had a short-lived API breakage introduced in commit [1], which was
workedaround in commit [2]. The original change, however, was reverted
shortly afterward in commit [3]. Since we require at least v2.0.0, there
is no need to keep this workaround.

[1] https://aomedia.googlesource.com/aom/+/4667aa1a373566e9c124afcd58c71731ab0d7377
[2] aaf9171574
[3] https://aomedia.googlesource.com/aom/+/9b1252eab0616d2c1f6d7990c6256441c0b6483f

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-22 07:05:58 +01:00
stevxiao
64b9be2dc5 avcodec/d3d12va_encode: support motion estimation precision mode
By default, the D3D12 video encoder uses MAXIMUM, which means no restriction—it uses the highest precision supported by the driver.

Applications may want to reduce precision to improve speed or reduce power consumption. This requires the encoder to support user-defined motion estimation precision modes.

D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE defines several precision modes:

maximum: No restriction, uses the maximum precision supported by the driver.
full_pixel: Allows only full-pixel precision.
half_pixel: Allows half-pixel precision.
quarter-pixel: Allows quarter-pixel precision.
eighth-pixel: Allows eighth-pixel precision (introduced in Windows 11).

Sample Command Line:

ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -extra_hw_frames 20 -i input.mp4 -an -c:v h264_d3d12va -me_precision half_pixel out.mp4
2025-12-22 05:35:04 +00:00
Gyan Doshi
1fcb201ab1 configure: update dependencies
These muxers - hls, tee, whip - open other muxers.
In addition, whip requires http protocol.
2025-12-21 04:16:10 +00:00
Leo Izen
784aa09fa8 avcodec/exif: parse additional EXIF IFDs
Most EXIF metadata is in IFD0 and most EXIF payloads only contain
one IFD, but it is possible for there to be more IFDs after the
existing trailing one. exiftool and similar software report these IFDs
as IFD1, IFD2, etc. This commit reads those additional IFDs and attaches
them as dummy entries in the top-level IFD ranging from 0xFFFC down to
0xFFED, which are unused by the EXIF spec. The EXIF API is only able to
return and work with a single IFD, so by attaching it as a subdirectory
this metadata can be preserved.

This is done transparently through the read/write process. Upon parsing
an additional IFD1, it will be attached, but it will be written with
av_exif_write after IFD0 rather than as a subdirectory, as intended.

Existing files without more than one IFD, i.e. most files, will be unaffected
by this change, as well as API clients looking to parse specific fields, but
now more metadata is parsed and written, rather than simply being discarded
as trailing data.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:23 -05:00
Leo Izen
105b6fcd9c avcodec/exif: avoid leaking EXIF metadata upon parse failure
Before this commit, exif_parse_ifd_list didn't free *ifd upon failure,
relying on the caller to do so instead. We only guarded some of the
calls against this function, not all of them, so sometimes it leaked.

This commit fixes this, so exif_parse_ifd_list freeds *ifd upon failure
so callers do not have to guard its invocation with a free wrapper.

Fixes: ossfuzz 440747118: Integer-overflow in av_strerror

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:21 -05:00
Niklas Haas
7505264b6a swscale/ops: update comment on SWS_COMP_EXACT
That the integer is "in-range" is implied by the min/max range tracking,
not the flag itself.
2025-12-20 13:52:45 +00:00
Niklas Haas
1d0fd7fabf swscale/ops: categorize ops by type compatibility
This is a more useful grouping than the previous, somewhat arbitrary one.
2025-12-20 13:52:45 +00:00
Niklas Haas
94777ed2eb swscale/ops_chain: fix comment 2025-12-20 13:52:45 +00:00
Niklas Haas
75ba2bf457 swscale/ops: correctly truncate on ff_sws_apply_op_q(SWS_OP_RSHIFT)
Instead of using a "precise" division, simulate the actual truncation.

Note that the division by `den` is unneeded in principle because the
denominator *should* always be 1 for an integer, but this way we don't
explode if the user should happen to pass `4/2` or something.

Fixes a lot of unnecessary clamps w.r.t. xv36, e.g.:

 xv36be -> yuv444p12be:
   [u16 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) packed >> 0
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_SWIZZLE      : 1023
   [u16 ...X -> ++++] SWS_OP_RSHIFT       : >> 4
-  [u16 ...X -> ++++] SWS_OP_CONVERT      : u16 -> f32
-  [f32 ...X -> ++++] SWS_OP_MIN          : x <= {4095 4095 4095 _}
-  [f32 ...X -> ++++] SWS_OP_CONVERT      : f32 -> u16
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     (X = unused, + = exact, 0 = zero)
2025-12-20 13:52:45 +00:00
Niklas Haas
d1eaea1a03 swscale/ops: add type assertions to ff_sws_apply_op_q() 2025-12-20 13:52:45 +00:00
Niklas Haas
258dbfdbc9 swscale/format: only generate SHIFT ops when needed
Otherwise, we may spuriously generate illegal combinations like
SWS_OP_LSHIFT on SWS_PIXEL_F32.
2025-12-20 13:52:45 +00:00
Niklas Haas
c31f3926d1 swscale/ops_optimizer: simplify loop slightly (cosmetic)
We always `goto retry` whenever an optimization case is hit, so we don't
need to defer the increment of `n`.
2025-12-20 13:52:45 +00:00
Niklas Haas
900d91b541 swscale/ops_optimizer: apply optimizations in a more predictable order
Instead of blindly interleaving re-ordering and minimizing optimizations,
separate this loop into several passes - the first pass will minimize the
operation list in-place as much as possible, and the second pass will apply any
desired re-orderings. (We also want to try pushing clear back before any other
re-orderings, as this can trigger more phase 1 optimizations)

This restructuring leads to significantly more predictable and stable behavior,
especially when introducing more operation types going forwards. Does not
actually affect the current results, but matters with some upcoming changes
I have planned.
2025-12-20 13:52:45 +00:00
Niklas Haas
c51c63058c swscale/ops_optimizer: don't commute clear with itself
These would normally be merged, not swapped.
2025-12-20 13:52:45 +00:00
Andreas Rheinhardt
b934dd1d4b avformat/whip: Fix leak of dtls_fingerprint
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:24 +01:00
Andreas Rheinhardt
34bc95ddfc avformat/whip: Check number of audio/video streams generically
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:21 +01:00
Andreas Rheinhardt
e252bc0c3d avformat/whip: Remove dead code
This is checked generically after
6070ea29de.
Also set AVOutputFormat.subtitle_codec explicitly in order
not to rely on AV_CODEC_ID_NONE to be zero.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:42:27 +01:00
Andreas Rheinhardt
6177af5acc avcodec/x86/lossless_videodsp: Avoid unnecessary reg push,pop
Happens on Win64.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:56:09 +01:00