Commit Graph

125359 Commits

Author SHA1 Message Date
Kacper Michajłow
cbdbb07900 Makefile: hide verbose command from linking step
They are part of LD(XX) step, and shouldn't be shown if verbose output
is not enabled.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-29 21:22:15 +00:00
Kacper Michajłow
abb2a04649 Makefile: skip STRIP step when stripping is disabled
Instead of showing `STRIP` followed by `skipping strip`.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-06-29 21:22:15 +00:00
James Almer
7ab12fd02a avformat/movenc: use frame_size for EAC3 when merging packets
Otherwise remainder calculations will not work correctly if the input packets
have smaller frame sizes.

Should fix issue #23600.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-29 14:00:25 -03:00
James Almer
df9caa03b8 avformat/movenc: preserve packet side data when merging eac3 packets
If the last packet fed to the muxer has skip samples side data, if it were to be merged
into a single packet, said side data would be lost as is.
Copy it to the merged packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-29 12:38:12 -03:00
James Almer
2e6d5dbdc2 avformat/movenc: drain buffered EAC3 packets
handle_eac3() will buffer a packet if it doesn't reach the desired num_blocks
value, but if it was the last one to be passed to the muxer, it will never be
written.
Fix this by writing it during mov_write_trailer().

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-29 12:38:12 -03:00
James Almer
dac8b3f367 avformat/movenc: read packet duration at the time it's needed
Reading it at the beginning of ff_mov_write_packet() means that any changes to it
that happen afterwards will not be taken into account for the remainer calculation.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-29 12:38:12 -03:00
James Almer
613d65d508 tests/fate/hevc: update ref file for the newest test
A recent change affected what stream_remux() prints, and the CI didn't detect it
because it ran before doing a fast-forward rebase.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-06-29 14:29:33 +00:00
jiangjie
98c766ec19 avcodec/hevc_mp4toannexb: handle packet-side hvcC extradata
Do not overwrite the output codecpar extradata after init(). Keep the currently active HEVC parameter sets in HEVCBSFContext instead.

When AV_PKT_DATA_NEW_EXTRADATA on an input packet carries hvcC extradata, convert it to Annex B, update the runtime extradata state, and remove the packet side data.

Also add a FATE test covering extradata reloads with hevc_mp4toannexb,hevc_metadata.
2026-06-29 14:06:29 +00:00
nyanmisaka
3f6bf150cb avutil/hwcontext_cuda: fix yuv420p V/U plane overlap in cuda_get_buffer()
Odd-height yuv420p result in incorrect calculations of the U-plane
address offset. The last row of the V-plane overlapped with and was
overwritten by the first row of the U-plane, leading to chroma artifacts.

```
ffmpeg -init_hw_device cuda=cu -filter_hw_device cu -f lavfi -i \
testsrc=s=1920x1081,format=yuv420p -vf hwupload -c:v hevc_nvenc \
-vframes 1 -y <OUTPUT>
```

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-06-29 10:59:33 +00:00
Niklas Haas
de6bcf5c05 fftools/ffmpeg_demux: only throttle readrate on the slowest stream
If streams are badly interleaved, then the readrate logic can end up
accumulating an ever-growing lag. Rather than looping over each stream
and sleeping for each stream individually based on the local DTS and lag
logic, pull the sleep out of the loop and only sleep once based on the
furthest-behind stream (i.e. the stream contributing the lowest sleep
duration).

To reproduce:

$ ./ffmpeg -re -i fallbeatcaptiontest.mp4 -c copy -f null -t 10 -

Before this commit, this would run at ~0.7x and accumulate an infinitely
growing lag in one stream. After this commit, both streams run at ~1x as
expected, after an initial burst period due to the bad (1s granularity)
interleaving.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-29 09:46:36 +00:00
Niklas Haas
e7be06c8bd fftools/ffmpeg_demux: remove unused variable
This is a dead assignment except on a single branch, so just define it
locally.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-29 09:46:36 +00:00
Niklas Haas
5c877416a5 fftools/ffmpeg_demux: skip finished/unstarted streams in readrate_sleep()
This shouldn't affect the actual behavior, as the initialization of ds->dts
(implicitly zero'd) and the previous calculation of stream_ts_offset
guarantees that the `if (pts <= stream_ts_offset) continue;` branch fires.

Mainly a minor clarification of the code for the upcoming refactor.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-29 09:46:36 +00:00
Michael Niedermayer
86708357d1 avformat/iamf_parse: check count_label against the available bytes
Fixes: unbounded allocation / denial of service
Fixes: tP59h4cpaFyg
Fixes: 4ee05182b7 (avformat: Immersive Audio Model and Formats demuxer)
Found-by: Adrian Junge (vurlo)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-28 23:57:40 +00:00
Umar Pathan
11ff18a6c8 avcodec/rasc: Check that 32-bit DLTA accesses stay within the row
Found-by: bikini (github.com/bikini/exploitarium)
Fixes: out of array access
Fixes: rowspill_128x1.avi / gen_rowspill_avi.py
Fixes: xGV79bIb7uAJ
2026-06-28 21:52:21 +00:00
Alexander Kanavin
9579983197 ffbuild/common.mak: ensure target directories are created before running shell redirects into them
Otherwise, occasional build races have been observed:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/37/builds/3001/steps/13/logs/stdio

/bin/sh: 4: cannot create fftools/resources/graph.css.min: Directory nonexistent
mkdir -p fftools/graph
/bin/sh: 1: cannot create fftools/resources/graph.html.gz: Directory nonexistent
make: *** [/srv/pokybuild/.../ffmpeg-8.0.1/ffbuild/common.mak:165: fftools/resources/graph.html.gz] Error 2
make: *** Waiting for unfinished jobs....
make: *** [/srv/pokybuild/.../ffmpeg-8.0.1/ffbuild/common.mak:145: fftools/resources/graph.css.min] Error 2

There's a separate rule for making those directories, but unfortunately
it's racing with the rules that expect the directories to exist. Rather
than add a Makefile dependency, I've injected the dir creation directly
into the commands that can otherwise fail - a proper fix would probably
add the rule rather.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
2026-06-28 20:29:15 +00:00
Philip Langdale
983d457c2b avfilter/vf_yadif_cuda: fix typos in algorithm
After looking at bwdif_cuda and finding some algorithm typos, we found similar
mistakes in yadif_cuda. Thanks to nyanmisaka for thinking to check.
2026-06-28 19:33:23 +00:00
Philip Langdale
587db45caf avfilter/vf_bwdif_cuda: fix typos in algorithm
It's been years, but took another look at the bwdif_cuda implementation and
there are a couple of typos sitting in there. Found them when I was doing a
comparison with the Vulkan implementation.

This probably explains the small PSNR differences we've noted in the past.
2026-06-28 19:33:23 +00:00
Zhao Zhili
97ba3c4a9a avcodec/ffv1enc_vulkan: fix format specifier for VkDeviceSize
Fix build warning on macOS:
> format specifies type 'size_t' (aka 'unsigned long') but the
> argument has type 'VkDeviceSize' (aka 'unsigned long long')

VkDeviceSize is typedef as uint64_t.
2026-06-28 18:27:44 +00:00
Zhao Zhili
0b4798f7ab fftools/ffmpeg: disable stdin interaction when fd 0 is closed
When the parent process closes stdin before launching ffmpeg, fd 0 is
left invalid. The first opened input file then reuses fd 0, and the
read_key() poll in the transcode loop reads from that input instead of
the terminal, stealing bytes and corrupting the stream.

Fixes #23539
2026-06-28 18:26:49 +00:00
Michael Niedermayer
7e4366cf51 avformat/mov: check current_dts for overflow
This includes a bunch of semi related checks that Fairy wanted added

Fixes: 498236160/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4526018559016960
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-28 17:38:11 +00:00
Zhao Zhili
97115451d0 swscale/rational64: remove unused av_gcd_q64 declaration
av_gcd_q64 was declared in rational64.h but never defined or used.

Signed-off-by: Zhao Zhili <quinkblack@foxmail.com>
2026-06-28 14:14:07 +00:00
Niklas Haas
71c01ff4f6 avformat/http: move ff_http_averror() to header
This is used by rtsp.c (and the upcoming libcurl.c) as well. Moving it to a
header prevents a link failure if http_protocol were to ever
become disabled.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-28 12:49:17 +02:00
Niklas Haas
bf77674b3e avformat/http: use explicit AVERROR_ names for fixed error codes
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-28 12:48:23 +02:00
Niklas Haas
ee2bc31032 avformat/http: imply keep-alive by default when beneficial
By turning it into a tristate that defaults to -1 (auto). Users can still
force a particular value for debugging.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-28 12:47:40 +02:00
Niklas Haas
1e1e95f1a2 avformat/http: make reconnection message less misleading
If using a keepalive connection, this does not actually reconnect.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-28 12:45:38 +02:00
Niklas Haas
2dbe4517f6 avformat/http: split request size determination to separate function
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-28 12:45:38 +02:00
Niklas Haas
a53a9af6c8 avformat/http: organize HTTP context fields into sections (cosmetic)
This is a best-effort attempt at re-organizing these fields a bit to
make it more clear what's used where and why.

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-28 12:45:38 +02:00
Michael Niedermayer
87bd15dc3c avcodec/ffv1enc: Reject odd dimensions for bayer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-28 00:22:09 +00:00
Michael Niedermayer
cc17277c36 avcodec/ffv1dec: Reject bayer with unaligned slice coordinates
Bayer was introduced (4f509c9e43) with combined_version 0x4000A, so no real
bayer stream uses the old unaligned coordinates; reject it. Odd picture
dimensions remain valid and are handled by aligning the bayer allocation to
2x2.

Fixes: out of array write
Fixes: fa6F4c0xA8el
Fixes: 4f509c9e43 (ffv1dec: implement Bayer pixel format encoding)
Found-by: Anonymous
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-28 00:22:09 +00:00
Michael Niedermayer
11afa309fb avcodec: Align bayer pixel formats to 2x2
Fixes: out of array access with odd dimensioned bayer
Fixes: fa6F4c0xA8el
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-28 00:22:09 +00:00
Martin Storsjö
8512161c81 configure: Pass the .objs response file to makedef
This fixes generating shared libraries with a toolchain that requires
makedef (MSVC, or mingw toolchains with LLD, that lacks support for
--version-script).

This uses the existing response file generated for linking, by
splitting out the choice of input parameter to makedef to a variable
expanded by make.

This avoids relying on "echo" within makedef supporting long command
lines; msys2/cygwin shells handle it fine, while busybox doesn't.
2026-06-27 11:32:54 +00:00
Martin Storsjö
32d7e9d71e configure: Test for response file support in a way that works with busybox-w32
Don't use /dev/null as test input file for the test for response
file support.

Busybox on Windows does provide POSIX utilities to the point of
being able to build and test ffmpeg, but it doesn't provide full
POSIX emulation like msys2 and cygwin do.

Busybox utils do handle paths like /dev/null themselves. But when
busybox invokes a native Windows executable (like the "$ar" tool
in this test), it passes such a path as-is. Msys2 on the other hand
rewrites unixy paths in command line parameters - even when prefixed;
e.g. "@/dev/null" gets rewritten into "@nul".

Instead of testing with a /dev/null input, test with a real temp
file instead.
2026-06-27 11:32:54 +00:00
Bogdan Lisman
d26ba5377d doc/muxers: document undocumented segment muxer options
write_header_trailer, individual_header_trailer, segment_header_filename and
segment_wrap_number had no documentation. Describe each option and the ways
they constrain one another.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
2026-06-27 04:03:37 +00:00
Andreas Rheinhardt
90cca8111b tests/checkasm/hevc_pel: Don't test impossible values
denom is in 0..7 (see pred_weight_table() in hevcdec.c).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-27 00:06:08 +02:00
Andreas Rheinhardt
baad19d0b5 avcodec/hevc/dsp: Combine offsets early for biweight prediction
Only the sum of the offsets is ever used
(see equation 8-279 in the 2019 version of the H.265 spec).

Tested-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-27 00:06:08 +02:00
Andreas Rheinhardt
01f29e05d3 avcodec/hevc/dsp: Fix epel_bi_w parameter names
It uses the same order as qpel_bi_w.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-27 00:06:08 +02:00
Andreas Rheinhardt
7dad1be1bf avcodec/hevc/hevcdec: Remove redundant clipping
Forgotten in f82dd4c09b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-27 00:06:08 +02:00
Andreas Rheinhardt
30fe4f148f avcodec/x86/hevc/mc: Use pmaddwd in biweight functions
Improves performance and saves 384B of .text here;
also avoids using nonvolatile registers on Win64.

Old benchmarks (just a selection):
  put_hevc_qpel_bi_w_v16_8_c:           1158.1
  put_hevc_qpel_bi_w_v16_8_sse4:         214.4 ( 5.40x)
  put_hevc_qpel_bi_w_v16_10_c:          2193.3
  put_hevc_qpel_bi_w_v16_10_sse4:        318.5 ( 6.89x)
  put_hevc_qpel_bi_w_v16_12_c:          2188.5
  put_hevc_qpel_bi_w_v16_12_sse4:        317.8 ( 6.89x)
  put_hevc_qpel_bi_w_v24_8_c:           2940.5
  put_hevc_qpel_bi_w_v24_8_sse4:         502.9 ( 5.85x)
  put_hevc_qpel_bi_w_v24_10_c:          4557.1
  put_hevc_qpel_bi_w_v24_10_sse4:        686.0 ( 6.64x)
  put_hevc_qpel_bi_w_v24_12_c:          4557.1
  put_hevc_qpel_bi_w_v24_12_sse4:        688.4 ( 6.62x)
  put_hevc_qpel_bi_w_v32_8_c:           3753.0
  put_hevc_qpel_bi_w_v32_8_sse4:         817.8 ( 4.59x)
  put_hevc_qpel_bi_w_v32_10_c:          6504.2
  put_hevc_qpel_bi_w_v32_10_sse4:       1227.7 ( 5.30x)
  put_hevc_qpel_bi_w_v32_12_c:          6502.0
  put_hevc_qpel_bi_w_v32_12_sse4:       1230.8 ( 5.28x)
  put_hevc_qpel_bi_w_v48_8_c:           7756.0
  put_hevc_qpel_bi_w_v48_8_sse4:        1805.9 ( 4.29x)
  put_hevc_qpel_bi_w_v48_10_c:         12938.4
  put_hevc_qpel_bi_w_v48_10_sse4:       2690.5 ( 4.81x)
  put_hevc_qpel_bi_w_v48_12_c:         12934.1
  put_hevc_qpel_bi_w_v48_12_sse4:       2691.2 ( 4.81x)
  put_hevc_qpel_bi_w_v64_8_c:          13212.5
  put_hevc_qpel_bi_w_v64_8_sse4:        3183.9 ( 4.15x)
  put_hevc_qpel_bi_w_v64_10_c:         21520.0
  put_hevc_qpel_bi_w_v64_10_sse4:       4854.9 ( 4.43x)
  put_hevc_qpel_bi_w_v64_12_c:         21529.5
  put_hevc_qpel_bi_w_v64_12_sse4:       4860.9 ( 4.43x)

New benchmarks:
  put_hevc_qpel_bi_w_v16_8_c:           1159.1
  put_hevc_qpel_bi_w_v16_8_sse4:         176.7 ( 6.56x)
  put_hevc_qpel_bi_w_v16_10_c:          2196.5
  put_hevc_qpel_bi_w_v16_10_sse4:        279.9 ( 7.85x)
  put_hevc_qpel_bi_w_v16_12_c:          2189.3
  put_hevc_qpel_bi_w_v16_12_sse4:        280.5 ( 7.80x)
  put_hevc_qpel_bi_w_v24_8_c:           2940.4
  put_hevc_qpel_bi_w_v24_8_sse4:         417.5 ( 7.04x)
  put_hevc_qpel_bi_w_v24_10_c:          4553.1
  put_hevc_qpel_bi_w_v24_10_sse4:        605.9 ( 7.51x)
  put_hevc_qpel_bi_w_v24_12_c:          4573.9
  put_hevc_qpel_bi_w_v24_12_sse4:        605.6 ( 7.55x)
  put_hevc_qpel_bi_w_v32_8_c:           3752.2
  put_hevc_qpel_bi_w_v32_8_sse4:         668.2 ( 5.61x)
  put_hevc_qpel_bi_w_v32_10_c:          6482.2
  put_hevc_qpel_bi_w_v32_10_sse4:       1077.4 ( 6.02x)
  put_hevc_qpel_bi_w_v32_12_c:          6484.9
  put_hevc_qpel_bi_w_v32_12_sse4:       1088.0 ( 5.96x)
  put_hevc_qpel_bi_w_v48_8_c:           7765.1
  put_hevc_qpel_bi_w_v48_8_sse4:        1467.8 ( 5.29x)
  put_hevc_qpel_bi_w_v48_10_c:         12902.8
  put_hevc_qpel_bi_w_v48_10_sse4:       2356.6 ( 5.47x)
  put_hevc_qpel_bi_w_v48_12_c:         12931.1
  put_hevc_qpel_bi_w_v48_12_sse4:       2356.6 ( 5.49x)
  put_hevc_qpel_bi_w_v64_8_c:          13207.2
  put_hevc_qpel_bi_w_v64_8_sse4:        2624.9 ( 5.03x)
  put_hevc_qpel_bi_w_v64_10_c:         21542.3
  put_hevc_qpel_bi_w_v64_10_sse4:       4438.8 ( 4.85x)
  put_hevc_qpel_bi_w_v64_12_c:         21537.4
  put_hevc_qpel_bi_w_v64_12_sse4:       4359.5 ( 4.94x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-27 00:06:08 +02:00
Niklas Haas
6baf561303 avfilter/vf_scale_cuda: fix inverted downscaling check
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
01972b4f85 avfilter/vf_scale_cuda: allocate inter buffer with correct subsampling
Since the input and output format can differ (e.g. 444 -> 420), we need to
reference the correct subsampling for the partially applied filter.

Keep track of this in the CUDATex itself.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
420a9e90b8 avfilter/vf_scale_cuda: allocate intermediate buffer directly
Instead of going via an AVFrame at all. This will allow us to fix the
intermediate chroma plane size for split downscaling.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
e79e9f06ba avfilter/vf_scale_cuda: use persistent intermediate CUDATex
Instead of re-creating this object every frame.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
4289a29bb0 avfilter/vf_scale_cuda: defer buffer allocation to setup_filters()
At this point, s->hwctx and CudaFunctions * are available.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
fef976b197 avfilter/vf_scale_cuda: introduce CUDATex and mapping helper
I want to disentangle the internal logic from AVFrame, because some
intermediate states (e.g. for partially subsampled chroma with simultaneous
scaling) may not directly map to a valid AVPixelFormat.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
61750318db avfilter/vf_scale_cuda: add fail: label (cosmetic)
Make the next commit a bit easier to review.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
0c3f04a97c avfilter/vf_scale_cuda: eliminate redundant context push/pop
This is already done by cudascale_filter_frame().

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Niklas Haas
ffe0104574 avutil/hwcontext_cuda: fix off-by-one in cuda_transfer_data()
Height of the chroma plane was computed using a naive right shift instead of
AV_CEIL_RSHIFT, leading to the last line of chroma being uncopied.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-26 21:54:47 +00:00
Michael Niedermayer
19035c35fc avcodec/mpeg4videodec: Copy studio_profile in frame-thread context update
Fixes: out of array access
Fixes: poc.m4v / make_poc.py
Fixes: 93KU7grvT7G1
Fixes: f9d3841ae6 (mpeg4video: Add support for MPEG-4 Simple Studio Profile.)
Found-by: VulnForge Security Research Team <haoyuliu@clouditera.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 21:17:14 +00:00
Jiale Yao
56309e476a avfilter/vf_vif: Fix out of array access with small dimensions
The hand written boundary mirroring reflected an out of range index only
once, which is insufficient when the image dimension is smaller than the
filter half width (filt_w/2 == 8). A 1x1 input made the index reach 8
and -7, reading out of the src[]/temp[] arrays. Use avpriv_mirror(),
which mirrors repeatedly and stays in range for any dimension.

Fixes: out of array access
Fixes: repro.sh
Fixes: HuQn51lLiVJX
Fixes: 38aea9b041 (avfilter: add vif filter)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 21:15:23 +00:00
Marco Reimann
f9482e1d01 avcodec/nellymoserdec: Check block count to avoid integer overflow
Fixes: out of array access
Fixes: nelly.avi / gen_nelly_overflow.py
Fixes: pgc86PfE7ZpA
Fixes: 0eea212943 (Add avcodec_decode_audio4().)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 21:14:51 +00:00