Commit Graph

12581 Commits

Author SHA1 Message Date
Lynne
90436de5e1 vf_libplacebo: add missing avstring.h include
Otherwise compilation fails due to vulkan.h no longer including it.
2026-07-13 18:57:38 +09:00
Lynne
92f2e6374d configure: remove libshaderc and libglslang support
All of it is now gone.
2026-07-13 18:57:38 +09:00
Lynne
9e9ac0dcd9 vulkan: remove runtime shader compilation support
No longer needed.
2026-07-13 18:57:37 +09:00
Lynne
6219d4fdd1 vf_scale_vulkan: port to compile-time SPIR-V generation
Same functionality as before, but cleaner.
2026-07-13 18:57:37 +09:00
James Almer
b662613b63 avfilter/af_aresample: also look for downmix matrix side data
Signed-off-by: James Almer <jamrial@gmail.com>
2026-07-11 19:32:17 -03:00
James Almer
6336cffdce avfilter/af_ashowinfo: support printing downmix matrix side data
Signed-off-by: James Almer <jamrial@gmail.com>
2026-07-11 19:32:17 -03:00
Philip Langdale
8ad6288553 avfilter/vf_libplacebo: add flag to inherit the input's Vulkan device
vf_libplacebo is unique in that it can function as both a Vulkan filter, and a
software filter, depending on how it the filter graph is configured. While this
is very flexible, it create a problem in situations where the filter does not
receive a Vulkan hw frames context up front. When that doesn't happen, it will
initialise its own standalone pl context, and then fail to interoperate with
a context provided via the input link. This then leads to graph failures.

There are two primary scenarios where this existing logic breaks what should
be valid configurations:
* When the global filter hw device is a cuda device and we use something like
  `hwupload=derive_device=vulkan` to pass frames from cuda to vulkan
* In mpv (and probably other media players) which don't set the global filter
  hw device at all. In this case, it's impossible to configure vf_libplacebo
  to use a hw frames ctx, even if it's using Vulkan for everythng else. This
  prevents the use of vf_libplacebo in any fully hardware accelerated pipeline
  in mpv

There are various ways we could imagine addressing it - such as allowing the
filter to discard the initial pl context and recreating it based on the passed
in device, but it's easier to reason about if we add a flag that explicitly
tells the filter that it should inherit the device context from the input link.
This puts the filter into a mode that works like all the other Vulkan filters.

This requires explicit configuration from the user, but the intent is clearer,
and the user can always know when it's necessary as they define the filter
graph.
2026-07-09 13:25:09 +00:00
Zhao Zhili
c57660fb18 avfilter/vf_scale_cuda: fix non-scaling format conversion
A format-only conversion leaves the auto use_filters value unresolved.
Regression since 5d0748243f.

Fix issue #23737

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-07-08 12:37:35 +00:00
Michael Niedermayer
a73d648f6e avfilter/vf_v360: keep remap source coordinates in bounds
Two runtime paths could compute out-of-range source coordinates for
degenerate projection geometry, causing heap-buffer-overflow reads

Fixes: out of array read
Fixes: assertion failure
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-07 17:43:18 +00:00
Michael Niedermayer
b3712addc9 avfilter/vf_v360: reject dimensions too small for the projection
Fixes: out of array read
Fixes: assertion failure
Fixes: mQzloVqnivHQ
Found-by: Anthony Hurtado
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-07 17:43:18 +00:00
Kacper Michajłow
c6498178bb avfilter/vsrc_gfxcapture_winrt: add missing system_error include
Fixes: error: no type named 'system_error' in namespace 'std'
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-07-06 06:39:19 +00:00
Jamaika1
c74f279559 avfilter/vf_quirc: Changed character specifier
```
vf_quirc.c: In function 'filter_frame':
vf_quirc.c:104:46: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'int64_t' {aka 'long long int'} [-Wformat=]
  104 |            "Found count %d codes in image #%ld\n", codes_count, inl->frame_count_out);
      |                                            ~~^                  ~~~~~~~~~~~~~~~~~~~~
      |                                              |                     |
      |                                              long int              int64_t {aka long long int}
      |                                            %lld
```
2026-07-05 22:31:27 +00:00
Andreas Rheinhardt
97cbffe917 all: Don't discard const through {mem,str,strr}chr
C23 made these generic functions that no longer cast const
away for you, leading to warnings when compiling with C23
and a recent enough toolchain (glibc supports this since 2.43).
This commit fixes all the warnings that can simply be fixed
by adding const, without adding casts.
(the latter excludes parse_forced_key_frames() in ffmpeg_mux_init.c).

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-07-05 09:02:40 +02:00
Vladimir Panteleev
e058e8c0c5 vf_photosensitivity: fix metadata when duplicating frames
When the blending factor was calculated to be 0, the hot path skipped
updating variables later emitted in metadata.

Fix the flow to ensure they are populated consistently.

Extend the FATE test suite to check metadata output.
2026-07-05 00:41:30 +00:00
Vladimir Panteleev
722493d3e1 vf_photosensitivity: add blend option
This commit attempts to address feedback from this filter's users, by
introducing a new option which controls the amelioration mechanism.

The "blend" option is a factor which is multiplied by the difference
in badness (between the threshold and the currently accumulated
badness). This difference normally controls how much of the next frame
we can let through without making it exceed the badness threshold.

Setting the option to zero effectively puts the filter into a mode
where it always duplicates the last frame (which did not put
accumulated badness over the threshold) instead of attempting to blend
in new frames.  I have received reports that this mode is preferable
to users for some types of media.
2026-07-05 00:41:30 +00:00
Vladimir Panteleev
734cbb6617 vf_photosensitivity: scale badness threshold with history size
This commit attempts to address feedback from this filter's users, by
improving the filter's behavior at the start of playback or
immediately after seeking.

In these situations, the history buffer is empty, but because we did
not previously track its size, we were calculating the weighted
average as if the corresponding frames had zero badness. This caused
the filter to behave differently and possibly produce false negatives
when the history was not fully populated.

Address this by instead taking into account the history size when
calculating cumulative badness. To accomplish this:

- Add a history_size field to to PhotosensitivityContext, tracking how
  much of the history buffer is populated.

- Change the semantics of PhotosensitivityContext::badness_threshold.
  Previously, it was premultiplied by the maximum history size. This
  is no longer done, so that we can multiply it to the live
  history_size on the fly instead.

- Calculate the badness threshold on a per-frame basis. The result is
  now stored in a badness_threshold local variable.

This commit only changes the filter's behavior for the first
PhotosensitivityContext::nb_frames (configurable as the "frames"
filter option) frames. For successively filtered frames, the behavior
is unchanged.
2026-07-05 00:41:30 +00:00
Michael Niedermayer
4da9812e25 avfilter/vf_quirc: resize the quirc buffers when the input size changes
Fixes: out of array access
Fixes: JbvzNObhorBp
Fixes: 030e140145 (lavfi: add quirc filter)
Found-by: Adrian Junge (vurlo)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-05 00:07:59 +00:00
tknaveen
766074133f avfilter/dnn_backend_torch: fix missing ret in async error path
ff_dnn_start_inference_async() return value was not stored in ret,
causing execute_model_th() to return success on async startup failure.
This left vf_dnn_processing stuck in its flush loop waiting on a
task that was never started.
2026-07-03 21:29:36 +08:00
Marvin Scholz
9448d5e084 avfilter/vf_mcdeint: add fall-through annotations 2026-07-02 18:23:18 +02:00
Pavel Kohout
0dac41d2e5 avfilter/boxblur: reject pixel formats deeper than 16 bits
Fixes: heap buffer overflow
Fixes: CRufFb6TVikL
Fixes: dee7440531 (vf_boxblur: Templatize blur{8,16})
Found-by: Pavel Kohout (Aisle Research)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-07-02 03:16:42 +00:00
Niklas Haas
a974a54486 avfilter: add less confusing error on frame queue overflow
Currently, such filter graphs just fail with a nebulous:

  [fc#0 @ 0x2a7b3c0] [error] Error while filtering: Cannot allocate memory

Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-07-01 12:12:15 +00:00
Michael Niedermayer
9a01c1cb6a avfilter/vf_removelogo: free the whole mask on allocation failure
Found-by: Ao Xijie
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-30 11:15:33 +00:00
Michael Niedermayer
59a5090070 avfilter/af_adeclick: free transform contexts and buffers on error
Found-by: Ao Xijie
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-30 11:05:29 +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
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
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
Michael Niedermayer
d66e84695b Bump minor after release/9.0 branch on master
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:47:51 +02:00
Michael Niedermayer
47e9d68e20 Bump minor for release/9.0
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:43:34 +02:00
Diego de Souza
df94900c98 avfilter/cuda: support P012/P212 and MSB 4:4:4 in scale/transpose/thumbnail
NVDEC and CUVID now output AV_PIX_FMT_P012 (12-bit 4:2:0), AV_PIX_FMT_P212
(12-bit 4:2:2) and AV_PIX_FMT_YUV444P10MSB / AV_PIX_FMT_YUV444P12MSB
(10/12-bit 4:4:4) for high-bit-depth content, but these CUDA filters
rejected the formats in their supported-format lists, breaking pipelines
such as "-hwaccel cuda ... -vf scale_cuda" on 12-bit input.

These formats use 16-bit sample storage, and the filters select their CUDA
kernel by byte-storage size and plane layout, not by the number of valid
bits, so they can reuse the existing 16-bit kernels:

- scale_cuda: P012/P212 -> "semiplanar16", YUV444P10MSB/YUV444P12MSB ->
  "planar16".
- transpose_cuda: the ushort/ushort2 kernels are chosen from the pixel
  descriptor (byte size + channel count); just allow the new formats.
- thumbnail_cuda: P012 reuses the P010/P016 path and the MSB 4:4:4 formats
  reuse the YUV444P16 path; P012 is added to the 4:2:0 chroma-histogram
  scaling as well. (thumbnail has no 4:2:2 path, so P212 is not added.)

The CUDA deinterlacers (bwdif_cuda, yadif_cuda) already accept any format
with <= 2 bytes per sample and <= 2 channels, so they need no change. The
8-bit-only filters (overlay_cuda, pad_cuda, bilateral_cuda, chromakey_cuda,
colorspace_cuda) do not support high bit depths and are left untouched.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-06-24 12:18:15 +00:00
Andreas Rheinhardt
2f59339479 avfilter/buffersink: Fix indentation
Necessary after 509c1f99a7.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 22:38:55 +00:00
Niklas Haas
9420146e6d avfilter/vf_scale_cuda: re-indent after previous change
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
5d0748243f avfilter/vf_scale_cuda: add use_filters option
This may be faster or slower than the existing specialized kernels,
so I opted not to prefer it by default. I also deliberately didn't expose
additional filter function capabilites yet.

The main motivating reason here is to get correct anti-aliasing behavior
when downscaling, which is currently completely broken.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
469281fa50 avfilter/vf_scale_cuda: add generic 1D filter kernel
This can be useful for any sort of separable filtering with arbitrary
weights.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
d98cc462f6 avfilter/vf_scale_cuda: generalize kernel signature to accept weights
Ignored for now by the existing fixed function kernels.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Niklas Haas
b400791442 avfilter/scale_filters: add internal copy of libswscale/filters.c
Useful for GPU-based filters, which may also need to compute filter weights.
Since we cannot cross-link to internal functions, we need to recompile this
helper inside libavfilter.c.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-23 19:22:21 +00:00
Andreas Rheinhardt
762b94e672 libs: Bump major version of all libraries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
2d3776b8cc avutil/x86/emms: Unavpriv avpriv_emms_asm()
This fallback function is used if external MMX is available,
while inline MMX and intrinsics for emitting emms are unavailable.
It is implemented as an avpriv function, which has several
drawbacks for shared builds:
1. The function is so small (3 bytes; 16 with padding)
that the overhead of exporting and importing it dwarfs
the gains from code deduplication.
2. A call to an external library has more overhead than
a library-internal one.
3. It may cause linking failures when a libavutil not exporting
avpriv_emms_asm() is paired with a library needing it
(if inline assembly and intrinsics were unavailable when building
the dependent library). I am not aware of this ever happening.
4. We would be forced to keep avpriv_emms_asm() around for ABI stability
even after it is no longer needed.

This commit therefore uses the STLIBOBJS, SHLIBOBJS approach
to duplicating it into each library on its own if needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
9f58e3014c avfilter: Remove FF_API_LIBNPP_SUPPORT
libnpp and the corresponding filters have been deprecated
in commit 994a368451
on 2025-09-26. By the time of our next release,
a year will have passed, so they are removed immediately.

Note: Passing --enable-libnpp to configure results in
a warning about the deprecation and is otherwise a no-op.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt
7116138857 avfilter/avfilter: Remove FF_API_CONTEXT_PUBLIC
Deprecated on 2024-10-07.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Andreas Rheinhardt
509c1f99a7 avfilter: Remove deprecated FF_API_BUFFERSINK_OPTS
Deprecated since 2024-09-30.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 17:15:02 +02:00
Jun Zhao
b08c9c5f53 lavfi/vf_subtitles: expose shaping option
The ass filter exposes libass' shaping mode selection so callers can
request complex shaping for scripts such as Arabic. The subtitles filter
uses the same renderer path but did not expose the option.

This left the zero-initialized shaping field to select
ASS_SHAPING_SIMPLE implicitly.

Expose the same shaping option for subtitles and default it to auto,
matching the ass filter. This allows subtitles=...:shaping=complex to
render Arabic lam-alef correctly when libass is built with HarfBuzz
support.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-06-23 03:57:25 +00:00
Kacper Michajłow
efa8b20987 vf_libplacebo: remove compatibility code with not supported versions 2026-06-22 16:18:59 +00:00